Send Email From A Custom App in AX
Posted Wednesday, July 8th, 2009
Say for instance a customer is writing custom code that is performing some function in DAX. After that process is done, they might want to send an email to notify either internal employees or external contacts. They can use this code to send an email. I know that workflow will notify internal employees, but if they don’t want to go through the setup and configuration of setting up workflow, they could use this code. One application I can think of would be AR cash receipts journal posting. When the journal is posted, custom code could be written to send the customer an email notifying them that their payment(s) have been received and applied. Just like the email you get when you pay your credit card online.
If an email needs to be send from a custom application, it can be done with the following code:
SysMailer mail;
;
mail = new SysMailer();
mail.SMTPRelayServer(“yourexchange.server”);
mail.fromAddress(“fromaddress@address.com”);
mail.tos().appendAddress(“toaddress@address.com”);
// Build the Message
mail.htmlBody(strfmt(“This is a test”));
mail.subject(strfmt(“Testing AX Email”));
mail.sendMail();
