public void sendMail() { SysMailerMessageBuilder messageBuilder = new SysMailerMessageBuilder(); Email toEmail; Email fromEmail; try { FromEmail = "fromemail@xyz.com"; toEmail = "toemail@xyz.com"; messageBuilder.setBody("Hello from D365", false); messageBuilder.setSubject("Email Test from D365"); messageBuilder.addTo(toEmail); // Note: not calling setFrom() defaults to the current user for SMTP client, whereas // when sent to Outlook any setFrom() value will be ignored since profiles on the client are used messageBuilder.setFrom(fromEmail); // Open the generated email in the configured client // Sends a message interactively, allowing the user to view and modify the message before SysMailerFactory::sendNonInteractive(messageBuilder.getMessage()); // Try using sendNonInteractive method too } catch (Exception::Error) { throw error("@SYS33567"); } }
This blog is contains coding reference related to Microsoft AX 2012 and D365 finance and operations and Power platform
Monday, January 23, 2023
Send Email from D365FO
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment