Friday, 22 March 2019

Create a mail using x++ code in D365

Remarks:

We have sent mail using x++ code using SysMailerMessageBuilder system classes

Code:


class EmailSendingCodes
{       
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {      
        SysMailerMessageBuilder messageBuilder = new SysMailerMessageBuilder();

        Email   toEmail;

        Email   fromEmail;

        

        try

        {

            toEmail = "wingsraam@gmail.com";

            FromEmail  = "wingsraam@outlook.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 is 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::sendInteractive(messageBuilder.getMessage());

            // Try using sendNonInteractive method too

        }

        catch (Exception::Error)

        {

            throw error("@SYS33567");

        }
    }

}

1 comment:

  1. The Best Casino Bonuses & Promotions in Canada
    In bet365 kor addition to 텐벳 먹튀 the many 아이 벳 different online gambling sites available in Canada, we'll also have list of 포커 디펜스 bonuses and promotions max88 available to players at the top

    ReplyDelete

Step-by-Step Guide to Restore a SQL BACPAC File - Microsoft dynamics D365 Fin & Ops

 Restore steps for bacpac file in to SQL server - Microsoft dynamics D365 Fin & Ops. Log in to LCS and navigate to the asset library. On...