Tuesday, December 31, 2013

Sending an e-mail using Outlook



We will send an e-mail using Outlook. We will incorporate customer data from the system into a template to create the e-mail's text.

In Dynamics AX, e-mails can be sent in several ways. One of them is to use Microsoft Office Outlook. The benefit of using Outlook is that the user can review e-mails and modify if required, before they are actually sent. Also, all the sent e-mails can be stored in the user's Outlook folders.

Before we start with the code, we need to create a new e-mail template. This is standard Dynamics AX functionality and can be found in Organization administration | Setup | E-mail templates. Open the E-mail templates form and create the following record:






















Next, click on the E-mail message button and enter the e-mail body, as shown in the
following screenshot:



















In the AOT, create a new job named SendCustReminderEmail with the following code (replace the customer account number with your own):
static void SendCustReminderEmail(Args _args)
{
     CustTable custTable;
     Map mappings;
     custTable = custTable::find('1101');
     mappings = new Map(Types::String, Types::String);
     mappings.insert('customer',custTable.name());
     mappings.insert('company',CompanyInfo::find().Name);
     mappings.insert('user',HcmWorker::find(DirPersonUser::current().worker()).name());
     SysINetMail::sendEMail('Reminder',custTable.languageId(),custTable.email(),mappings);
}

Run the job, and click on the Allow button once Microsoft Outlook displays the
following security warning:













To review the results, open Outlook and look for the newly created message in either
the Outbox or Sent Items folders. Note that all placeholders were replaced with
actual values from the system:



Thats all you are ready to go..!!

IaceTechnologies a nd Services.

No comments:

Post a Comment