Home dynamics ax ax 2012 – email sent
dynamics ax

ax 2012 – email sent

hi everyone, 

this tutorial is how to make a email sender using ax 2012

static void HpJbTestEmail(Args _args)
{
    #SysMailer
    LanguageId languageId;

    SMTPRelayServerName relayServer;
    SMTPPortNumber      portNumber;
    SMTPUserName        userName;
    SMTPPassword        password;

    SysMailer mailer;
    System.Exception e;
    SysEmailParameters emailParams = SysEmailParameters::find();

    str 200             messageBody;
    ;

    relayServer = emailParams.SMTPRelayServerName;
    portNumber  = emailParams.SMTPPortNumber;
    userName    = emailParams.SMTPUserName;
    password    = SysEmailParameters::password();

    messageBody = "testing from ax ";

    try{
        mailer      = new SysMailer();
        mailer.SMTPRelayServer(relayServer,portNumber,userName,password, emailParams.NTLM);

        mailer.fromAddress("ronny@erakarta.com");
        mailer.tos().appendAddress("yourcustomer@mail.com");
        mailer.subject(strFmt("Testing - %1", systemDateGet()));
        mailer.htmlBody(messageBody);
        mailer.sendMail();
    }
    catch(Exception::Error)
    {
        error("we got error");
    }

    info(strFmt("%1|%2|%3|%4", relayServer,
        portNumber, userName, password));
    info("done test");
}

How to set Email parameter?

  • System Administration > Setup > System > Email Parameter

How to set email templates

  • Organization Administration > Setup > Email Templates

 

 

Author

Ronny

Leave a Reply