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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

To, CC, BCC recipients while sending emails using X++

(1) ShareShare
ReportReport
Posted on by 23
Hi community,
 
I am working on a requirement where I need to send emails to people using To, CC and Bcc recipients.
 
One solution that I see is to use SMTP client to send using X++, but we are having some technical issues with our SMTP server.
 
Second, If I want the email distributor batch to send my email using the selected email provider (SMTP/Graph/Exchange), how can I specify the cc and Bcc emails while creating a record in the SysOutgoingEmailTable?
 
Third, If I want to send email using Graph, how to do it in X++, and will it allow me to specify the To, cc and Bcc emails?
 
Thanks in advance.
 
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at
    You don't have to use the email distributor batch to use the other email providers. Look at How to send emails from code in AX 7, where I explained providers and showed code for constructing and sending a message. If you don't want to change your default provider, you can construct a specific one in code.
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,390 Super User 2025 Season 2 on at
    Hi @Sohan,
     
    you can use SysMailerMessage et SysMailer classes.
     
    e.g.
    void sendEmail()
    {
      str senderEmail = "sender@example.com";
      str recipientEmail = "recipient@example.com";
      str subject = "Hello";
      str body = "This is the email body.";
    
      SysMailer mailer = SysMailer::construct();
      SysMailerMessage message;
    
      message.setFromAddress(senderEmail);
      message.addToAddress(recipientEmail);
      message.addCc("cc@exemple.com");
      message.addBcc("bcc@exemple.com");
      message.setSubject(subject);
      message.setBody(body);
      mailer.sendEmail(message);
    
    }
    Best regrads,
    Mohamed Amine MAHMOUDI
  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at
    SysMailer class doesn't exist in D365FO.
     
    Instead, you can use classes like SysMailerSMTP or SysMailerExchange, but the recommended (extensible) approach is creating an instance through SysMailerFactory, as I demonstrated in the blog post.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans