D365 Business Central: Send email using email message and email accounts

Introduction:

Hello All,

This blog explains the new replaced objects provided by Microsoft for SMTP and showcases its working to send emails using the new replaced objects.

We have widely used SMTP Mail setup and SMTP Mail to send email notification in NAV and early versions of Business central but as SMTP Mail setup(Record 409) and SMTP Mail (codeunit 400) has been marked for removal and will be deprecated soon, Microsoft has provided a replacement for these objects.

  • Email Message – replaces SMTP Mail
  • Email Accounts – replaces SMTP Mail setup

Pre-requisites:

  1. Business central
  2. Visual studio code

Steps:

  1. Firstly, we need to set up an email account i.e the sender’s email account in business central. Navigate to the search bar and type email account.
  2. Click on New and select add an email account.
Add an email account

3. It will pop up with three options as above

  • Microsoft 365 – You can configure a Microsoft 365 shared mailbox as a sender’s email to send emails.
  • Current user – You can send emails using the user’s login email credentials
  • SMTP – You can send emails using SMTP server connector.

4. If you choose SMTP, click on apply office 365 server settings and add the mandatory fields

5. In my blog, I’m triggering an email whenever there is change in purchase direct cost.

  • Here, using Record Email Account to create an SMTP Connector
  • Body message is a text variable to story the email text along with html tags
  • Codeunit Email Message is used to create an email message with list of recipients,subject, body and htmlformatted. As I’ll be using html tags, I’ve marked them as true.
  • Codeunit Email is used to send the email.

The output email as below

Thank you for reading!

Original Post https://chrisdsilvablog.wordpress.com/2022/04/04/d365-business-central-send-email-using-email-message-and-email-accounts/

0 Votes: 0 Upvotes, 0 Downvotes (0 Points)

Leave a reply

Join Us
  • X Network2.1K
  • LinkedIn3.8k
  • Bluesky0.5K
Support The Site
Events
March 2025
MTWTFSS
      1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31       
« Feb   Apr »
Follow
Sign In/Sign Up Sidebar Search
Popular Now
Loading

Signing-in 3 seconds...

Signing-up 3 seconds...