Send email by using SysMailer

There are several methods to send email in Axapta. Using SysMailer is one of those.

Method 1 (Normal):
static void Email1(Args _args)
{
    SysMailer mailer  = new SysMailer();
    ;
    
    mailer.quickSend("mike@abc.com","mike@abc.com","subject","body");
}
Method 2 (Simple):
static void Email2(Args _args)
{
    SysMailer mailer  = new SysMailer();
    SysEmailParameters parameters = SysEmailParameters::find();
    ;

    if (parameters.SMTPRelayServerName)
    {
        mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
                           parameters.SMTPPortNumber,
                           parameters.SMTPUserName,
                           SysEmailParameters::password(),
                           parameters.NTLM);
    }

    mailer.fromAddress("mike@abc.com");
    mailer.tos().appendAddress("mike@abc.com");
    mailer.htmlBody("hi");
    mailer.sendMail();
}

Comments

Popular posts from this blog

Post packing slip of sales order in X++