如何使用genexus evo 3为网络发送电子邮件

本文关键字:网络 电子邮件 何使用 genexus evo | 更新日期: 2023-09-27 18:00:56

有人能帮我解决这个问题吗。

我试图使用一些数据类型,如SMTSession、MailMessage、MailRecipient。

但它不起作用。

这是代码

    &SMTPSession.Host                  = 'smtp.gmail.com'<br>
    &SMTPSession.Port               = 465<br>
    &SMTPSession.Authentication     = 1<br>
    &SMTPSession.UserName           = 'XXXX@gmail.com'<br>
    &SMTPSession.Password           = 'password'<br>
    &SMTPSession.Secure             = 1 <br>
    &SMTPSession.Sender.Address     = 'XXXX@gmail.com'<br>
    &SMTPSession.Sender.Name        = 'OtherName'<br>
    &MailRecipient.Address          = 'XXXX@hotmail.com'<br>
    &MailRecipient.Name             = 'Name'<br>
    &MailMessage.Subject            = 'Subject'<br>
    &MailMessage.Text               = 'text'<br>
    &MailMessage.To.Add(&MailRecipient)<br>

    &SMTPSession.Login()
    if &SMTPSession.ErrCode <> 0
        &SMTPSession.Send(&MailMessage)  
        &SMTPSession.Logout()
   endif

Genexus Evolution 3升级2,.Net环境,Web

如何使用genexus evo 3为网络发送电子邮件

尝试587端口。

你能添加错误描述吗?

您是否已在应用程序池IIS中启用32位应用程序?

代码看起来不错。与我所做的唯一不同的是,我写了&error=&SMTPSession.Login((

你正在使用的Gmail帐户没有启用两步验证?

您的代码完全正常,只是错过了发送前的状态检查,

&SMTPSession.Login()
if &SMTPSession.ErrCode = 0 // 0 = OK
    &SMTPSession.Send(&MailMessage)  
    &SMTPSession.Logout()
else
   //Msg(&SMTPSession.ErrDescription) // to see what kind of error
endif

在我的案例中,我使用了Gmail SMTP,端口是587

为了从GX程序发送邮件,您必须在发件人谷歌帐户中激活允许不太安全的应用程序的选项。