Official Content

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".



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 = ''
    &SMTPSession.Port = 465
    &SMTPSession.Timeout = 20
    &SMTPSession.Secure = 1
    &SMTPSession.Authentication = 1
    &SMTPSession.UserName = ''
    &SMTPSession.Password = '**********************'
    &SMTPSession.Sender.Address  = ''
    &SMTPSession.Sender.Name  = ''
    &ret = &SMTPSession.Login() 
    if &SMTPSession.ErrCode <> 0 
       &MailMsg = &ret.ToString() + ':Error al loguease'
       Do 'ManageError'                     //subroutine that manages errors  
       &MailMsg = "login OK"               //&MailMsg is based on the varchar data type
       &MailMessage.Clear()                //&MailMessage is based on the [[MailMessage Data Type]]
       &MailMessage.Subject="Email Subject XXX"
       &MailMessage.Text="Message body" 

       &MailRecipient.Address = ""   //&MailRecipient is based on the [[MailRecipient Data Type]]
       &MailRecipient.Name = "xxx"    
       &sendmsg = &SMTPSession.Send(&MailMessage)    
       &ret = &SMTPSession.Logout()

See Also

Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant