Firstly, it is made an extension to the enum “Email Scenario” in which are added all the scenarios intended. It should be taken into consideration that one must have as many scenarios as combinations of recipient/subject/body (although it is advised to have as many as combinations of recipient/subject/body/attachment).
Secondly, it is created the email sending process itself by instantiating the “Email Message” codeunit, by calling the Create procedure with the Recipient, Subject, Body and HtmlFormatted parameters respectively. Then, this email is sent by the “Email” codeunit in a chosen scenario.
The next step is to set up the accounts from which the emails will be sent. To demonstrate it, two accounts were configured in the “Email Accounts” page. The steps are as follows:
- Click the action “Add an email account”
- Start the wizard
- Select SMTP Account Type
- Fill the credentials and Sender information.
The “Server Url”, “Server Port”, “Authentication”, “User Name” and “Password” are set as they were in NAV. The “Sender Name” and the “Email Address” identify the e-mail from which the e-mails will be sent.
Notice that, although both accounts are configured with the same SMTP credentials (namely the username email@example.com and respective password) the emails are sent from the email set on the field “Email Address”.
In the “Email Accounts” page, the “Email Scenarios” are then assigned to a certain account by selecting “Email Scenarios” on the Navigate bar and then choosing “Assign Email Scenarios”. Take into consideration that a certain scenario can only be assigned to one “Email Account”.
As a result, in this simple example, the Vendors would receive an email from firstname.lastname@example.org stating that their ‘Phone No.’ was missing.