Unifies interaction functions with the sending and reception of messages for the different languages generated.
An important advantage of this implementation is that it enables the use of more than one connection event to the mail server.
It allows you to use a mail session to send messages through a server using the SMTP protocol (Simple Mail Transfer Protocol).
To use this feature, the requirement is to have TCP/IP protocol installed. It does not require Microsoft Office.
Note: The AuthenticationMethod property can be used since GeneXus 17 Upgrade 9 because it is related to a new implementation of the data type. Momentarily, this implementation is not active by default. To activate it, you have to create a file named "config.gx" under the Knowledge Base root directory containing the following line: "SMTPSession=MailKit".
Scope
Generators: .NET, .NET Framework, Java
The following sample is for Gmail and shows the configuration of some properties for a variable based on the SMTPSession data type:
&SMTPSession.Host = 'smtp.gmail.com'
&SMTPSession.Port = 465
&SMTPSession.Timeout = 20
&SMTPSession.Secure = 1
&SMTPSession.Authentication = 1
&SMTPSession.UserName = 'Info@gmail.com'
&SMTPSession.Password = '**********************'
&SMTPSession.Sender.Address = 'Info@gmail.com'
&SMTPSession.Sender.Name = 'Info@gmail.com'
&ret = &SMTPSession.Login()
if &SMTPSession.ErrCode <> 0
&MailMsg = &ret.ToString() + ':Error al loguease'
Do 'ManageError' //subroutine that manages errors
else
&MailMsg = "login OK" //&MailMsg is based on the varchar data type
&MailMessage.Clear() //&MailMessage is based on the [[MailMessage Data Type]]
&MailMessage.To.Clear()
&MailMessage.BCC.Clear()
&MailMessage.CC.Clear()
&MailMessage.Subject="Email Subject XXX"
&MailMessage.Text="Message body"
&MailMessage.Attachments.Clear()
&MailRecipient.Address = "xxx@gmail.com" //&MailRecipient is based on the [[MailRecipient Data Type]]
&MailRecipient.Name = "xxx"
&MailMessage.To.Add(&MailRecipient)
&MailMessage.CC.Add(&MailRecipient)
&MailMessage.BCC.Add(&MailRecipient)
&sendmsg = &SMTPSession.Send(&MailMessage)
&ret = &SMTPSession.Logout()
endif