Can we empower the option to choose the Sender email ID while sending an email in Business Central?

The answer is yes, with using of Email Scenario.

Lets start step by step how to achieve that

First of all we need to understand how email scenario works, in recent versions we use to have SMTP connection for sending the emails, where we can easily use of From Address(Sender email) before sending any email to our recipient.

Now we the current version of Business central from version 17 onwards you can start using of Extend Email Capabilities follow here with Microsoft learning documents. and here for using of the email scenarios

There are many inbuilt email scenarios available as per the below list.

Before using of Email scenarios we need to first setup of email accounts in BC central, you can read the steps from here

  • After setup the email account we can follow the below steps.

    1. Click on the Email account where you want to use the email scenariosEmail

    2. After opening the email scenario windows, you will see that the default email account is selected where we can choose any of the inbuilt scenario and assign, see belowEmail Scenario

    3. In my case I have choose Finance charge.Email ScenarioNow what does it mean to choose the finance charge, It means whenever the user will send the Finance charge report, it will always use that From address while sending an email.

    4. Now question is can we create our own Email scenario to send with multiple from addresses? The answer is Yes, Lets start how to do that using AL code.

 

To Create the custom email scenario we can use below steps:

  • We need to extend the email scenario Enum like below

enumextension 70001 "MY EmailSenarios" extends "Email Scenario"
{
value(70001; "Custom EmailScenario")
{
Caption='Custom EmailScenario';
}
}
  • After extending the AL code of Enum scenario

  • Publish the code and you will see that custom email scenario has been visible in the Email scenario list.

  • Email

  • var Email: Codeunit Email; 
    EmailMessage: Codeunit "Email Message"; 
    EmailScenario: Enum "Email Scenario"; 
    begin // Your code here to create the email message. 
    //EmailMessage.Create(); 
    email.Send(EmailMessage,EmailScenario::"Custom EmailScenario"); 
    end;

     

  • Send the email and check you will receive the email from the Assigned scenario email address you had defined earlier.

 

By using the above method, if you have multiple email accounts in the your BC, you can choose the desired email id as a Sender’ email to your Recipient email’s inbox.

 

Thanks for visiting my blog.

 

let me know if there is question.