web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

How to change 'from address' when sending email in an AL Extension

(0) ShareShare
ReportReport
Posted on by 911

I've setup an email account in BC (type: Smtp).

I have a procedure (see code below) which is working fine except that the From Address is coming from the Email Account and not from the code below.

procedure SendEnhancedEmail()
var
recTempEmailItem: Record "Email Item" temporary;
begin
Clear(recTempEmailItem);
recTempEmailItem.Reset();
recTempEmailItem.Init();
recTempEmailItem.Initialize();
recTempEmailItem."From Address" := 'nick.webb@o-net.co.uk';  // <- This line is being ignored.
recTempEmailItem."Send to" := 'nick.webb@o-net.co.uk';
recTempEmailItem.Subject := 'This is a test subject';
recTempEmailItem.SetBodyText('This is a test body.<br>This is Line 2.');
recTempEmailItem.Insert();
recTempEmailItem.Send(true, "Email Scenario"::Default);

end;

How do I set the From Address at runtime in an AL extension?

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    yes in the BC if we are creating an email and sending with new email features in general we don’t have any option to modify send from address, as it pick up the from addresses from the default email account setup.

    thanks

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    You can also use the email scenarios which are ready to extend.

  • Suggested answer
    YUN ZHU Profile Picture
    101,846 Super User 2026 Season 1 on at

    Hi, I checked the source code and it looks like the "From Address" is retrieved in the Send() function.

    pastedimage1653955879276v1.png

    pastedimage1653955920694v2.png

    pastedimage1653955961978v3.png

    So, as Nitin mentioned, you should manage "From Address" in Email Scenario feature.

    More details: https://docs.microsoft.com/en-us/dynamics365/business-central/admin-how-setup-email#assign-email-scenarios-to-email-accounts

    pastedimage1653956010975v4.png

    pastedimage1653956016593v5.png

    Hope this helps as well.

    Thanks.

    ZHU

  • Nick Webb Profile Picture
    911 on at

    Thanks all for your help.

    So, what if you want to use SMTP but you still want to be able to specify the 'From Address', as we have been able to do up until the last release? The only way I can think to make it work is to create an SMTP Email Account & Scenario for each employee / user, don't specify the 'From Address' in code and pass in the Scenario in the "Email Item".Send method, which will then take the from Address from the Email Account via the scenario. Of course, seeing as the Scenarios are members of an extended Enum, a program change would be required every time a new employee is encountered. Clanky huh? Is there a better way?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,454 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,806 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,538

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans