Showing posts with label How to sent mail in D365. Show all posts
Showing posts with label How to sent mail in D365. Show all posts

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");

        }
    }

}

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...