Skip to main content

Notifications

Community site session details

Community site session details

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

How to Change From Email ID using Email Message Codeunit - BC V19

(0) ShareShare
ReportReport
Posted on by 256

Hi All,

Below
"SMTP Mail Setup" and "SMTP Mail" are set for Mark for removal in business central.
I have one question when I upgrade the code regarding E-mail.
I have used the below object Codeunit "Email Message" and Email.
but I have did not find any way to change from name and From address while using the below function accordingly new object
"Email Message".Create(ToRecipients: List of [Text], Subject: Text, Body: Text, HtmlFormatted: Boolean, CCRecipients: List of [Text], BCCRecipients: List of [Text])
but in the Previous object function, we can change the from name and From address value.
like.
"SMTP Mail".CreateMessage(FromName: Text, FromAddress: Text, Recipients: List of [Text], Subject: Text, Body: Text, HtmlFormatted: Boolean)
I want to send mail according to the salesperson's email [FromAddress]. salesperson are many and we can not set many email accounts in business central.
Is that any way we can achieve it using "Email Message".Create(ToRecipients: List of [Text], Subject: Text, Body: Text, HtmlFormatted: Boolean, CCRecipients: List of [Text], BCCRecipients: List of [Text])
  • Ganesh2002 Profile Picture
    56 on at
    RE: How to Change From Email ID using Email Message Codeunit - BC V19

    I am having a similar issue. We want to use the default SMTP email for job queues. We have a custom code that sends email notifications (outside our company when the button is clicked). We want to send it from the user's account. I tried both Email Accounts and created a new scenario for the Current User. It is not working. It is still sending it from our default account.

  • Ganesh2002 Profile Picture
    56 on at
    RE: How to Change From Email ID using Email Message Codeunit - BC V19

    My sincere apologies. I had some issue with the browser. It got posted multiple times. 

  • Ganesh2002 Profile Picture
    56 on at
    RE: How to Change From Email ID using Email Message Codeunit - BC V19

    I am having the same issue. I tried both Email Accounts and Email Scenarios. We want to use SMTP for job queues. It is set as default. We have a custom code that sends notification outside of our company (when the button is clicked). We want to send it from the "Current User".  It is not working. It is still sending from SMTP I created a new scenario and assigned it to the current user.  

    lEmailCu.Send(lEmailMessageCu, "Email Scenario"::"Dispatch Tech");

  • Ganesh2002 Profile Picture
    56 on at
    RE: How to Change From Email ID using Email Message Codeunit - BC V19

    I am having the same issue. I tried both Email Accounts and Email Scenarios. We want to use SMTP for job queues. It is set as default. We have a custom code that sends notification outside of our company (when the button is clicked). We want to send it from the "Current User".  It is not working. It is still sending from SMTP I created a new scenario and assigned it to the current user.  

    lEmailCu.Send(lEmailMessageCu, "Email Scenario"::"Dispatch Tech");

    4744.pastedimage1660233561255v1.png

  • Ganesh2002 Profile Picture
    56 on at
    RE: How to Change From Email ID using Email Message Codeunit - BC V19

    I am having the same issue. I tried both Email Accounts and Email Scenarios. We want to use SMTP for job queues. It is set as default. We have a custom code that sends notification outside of our company (when the button is clicked). We want to send it from the "Current User".  It is not working. It is still sending from SMTP I created a new scenario and assigned it to the current user.  

    lEmailCu.Send(lEmailMessageCu, "Email Scenario"::"Dispatch Tech");

    2772.pastedimage1660233561255v1.png

  • Ganesh2002 Profile Picture
    56 on at
    RE: How to Change From Email ID using Email Message Codeunit - BC V19

    I am having the same issue. I tried both Email Accounts and Email Scenarios. We want to use SMTP for job queues. It is set as default. We have a custom code that sends notification outside of our company (when the button is clicked). We want to send it from the "Current User".  It is not working. It is still sending from SMTP I created a new scenario and assigned it to the current user.  

    lEmailCu.Send(lEmailMessageCu, "Email Scenario"::"Dispatch Tech");

    pastedimage1660233561255v1.png

  • Nick Webb Profile Picture
    797 on at
    RE: How to Change From Email ID using Email Message Codeunit - BC V19

    Did you ever reach a satisfactory solution to this one? If yes, please give brief description?

  • NeoMatrix Profile Picture
    256 on at
    RE: How to Change From Email ID using Email Message Codeunit - BC V19

    Hi Inge M. Bruvik, could you show the sample code for  "Send(Codeunit "Email Message", Record "Email Account")". How i can use "Email Account" record and Pass the to  the function.Send(Codeunit "Email Message", Record "Email Account")

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,029 Moderator on at
    RE: How to Change From Email ID using Email Message Codeunit - BC V19

    Using the email codeunit you basically have 3 options of controlling the sender address:

    (19.1.31886.32760), 'Send(Codeunit "Email Message", Enum "Email Scenario")' defined in Codeunit 'Email' by the extension System Application by Microsoft (

    19.1.31886.32760), 'Send(Codeunit "Email Message", Record "Email Account")' defined in Codeunit 'Email' by the extension System Application by Microsoft

    (19.1.31886.32760), 'Send(Codeunit "Email Message", Guid, Enum "Email Connector")' defined in Codeunit 'Email' by the extension System Application by Microsoft

    So either email scenario, Email account or Email connector.

    So best practice  and my recommendation would be to go with one of these options. 

    You have some events in the Email table that might be useful but they might break some security  rules on your mail service so you might end up with email not being sent anyway. 

  • NeoMatrix Profile Picture
    256 on at
    RE: How to Change From Email ID using Email Message Codeunit - BC V19

    Thanks for Reply. Yes we can add "email scenario". But In My Case I have customize email code on button. I have to send Email to Customer and the From email id must be on Salesperson email id. And there is lot of salesperson code and not feasible to setup email account and if new sales person add we need to setup email account. SO is there any event or we can set From email id using email message

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 1,452

#2
YUN ZHU Profile Picture

YUN ZHU 1,313 Super User 2025 Season 1

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 1,083 Most Valuable Professional

Featured topics

Product updates

Dynamics 365 release plans