How to send email with 1 email account ? (not SMTP)

julkifli33julkifli33 Member Posts: 1,092
Hi all,
I have customized something that send notification to vendor using SMTP account.
so no matter who click send email, it will be sent using SMTP email account.
(let's say : admin@abc.com)

understood that SMTP is no longer can be used in BC 20,
so we should use email account.

but how do we set only this email account to send ?
i want all the documents to be sent by admin@abc.com instead of personal email.

Thanks.

Best Answers

  • BertVerbBertVerb Member Posts: 24
    Answer ✓
    That table to the Email - smtp extension.
    So if you install Thst extension, found on appsource. You can use smtp emailing.

    See also
    https://docs.microsoft.com/en-us/dynamics365/business-central/admin-how-setup-email#legacy-smtp-settings-and-the-email---smtp-connector-extension
  • BertVerbBertVerb Member Posts: 24
    Answer ✓
    You can use the function AddRecipient(RecipientType: Enum "Email Recipient Type"; Recipient: Text)
    And recipientType you can choose to, cc or bcc because it is an enum.
  • ftorneroftornero Member Posts: 524
    Answer ✓
    Hello @julkifli33,

    You can use EmailMessage.Create with this signature and pass the CC or BC that you want
        /// <summary>
        /// Creates the email with recipients, subject, and body.
        /// </summary>
        /// <param name="ToRecipients">The recipient(s) of the email. A list of email addresses the email will be send directly to.</param>
        /// <param name="Subject">The subject of the email.</param>
        /// <param name="Body">The body of the email.</param>
        /// <param name="HtmlFormatted">Whether the body is HTML formatted.</param>
        /// <param name="CCRecipients">The CC recipient(s) of the email. A list of email addresses that will be listed as CC.</param>
        /// <param name="BCCRecipients">TThe BCC recipient(s) of the email. A list of email addresses that will be listed as BCC.</param>
        procedure Create(ToRecipients: List of [Text]; Subject: Text; Body: Text; HtmlFormatted: Boolean; CCRecipients: List of [Text]; BCCRecipients: List of [Text])
        begin
            EmailMessageImpl.Create(ToRecipients, Subject, Body, HtmlFormatted, CCRecipients, BCCRecipients);
        end;
    

    Regards

Answers

  • BertVerbBertVerb Member Posts: 24
    You can still use SMTP in BC20 with the new email feature.
    But you can also put a shared mailbox or setup a user account mail and attach that to the scenario.
  • julkifli33julkifli33 Member Posts: 1,092
    hi @BertVerb ,
    I just received this notification :
    "Error AL0433: Table 'SMTP Mail Setup' is removed. Reason: Moved to "Email - SMTP" app. Use SMTP connector to create SMTP accounts. Email accounts can be configured from "Email Accouts" page from "System Application".. Tag: 20.0."

    isnt we cant use SMTP Mail Setup anymore?
  • BertVerbBertVerb Member Posts: 24
    Answer ✓
    That table to the Email - smtp extension.
    So if you install Thst extension, found on appsource. You can use smtp emailing.

    See also
    https://docs.microsoft.com/en-us/dynamics365/business-central/admin-how-setup-email#legacy-smtp-settings-and-the-email---smtp-connector-extension
  • julkifli33julkifli33 Member Posts: 1,092
    edited 2022-04-06
    hi @BertVerb
    thanks for your url link
    i managed to send using new email connector
    but do you have any idea how to add cc and bcc?

    Old code
    SMTPMail.CreateMessage(CompanyInformation.Name,
    SMTPMailSetup."User ID", ToAddress, EmailSubject, BodyTextEmail);
    SMTPMail.AddCC(CCEmail);
    SMTPMail.AddBCC(BCCEmail);    
    SMTPMail.Send;
    

    New Code
            EmailMessage.Create(ToAddress, EmailSubject, BodyTextEmail, true);
            Email.Send(EmailMessage, Enum::"Email Scenario"::Default); 
    

    i tested but i cant find how to add cc and bcc
  • BertVerbBertVerb Member Posts: 24
    Answer ✓
    You can use the function AddRecipient(RecipientType: Enum "Email Recipient Type"; Recipient: Text)
    And recipientType you can choose to, cc or bcc because it is an enum.
  • julkifli33julkifli33 Member Posts: 1,092
    edited 2022-04-07
    Hi @BertVerb ,
    got it !
    Thanks a lot !
    EmailMessage.GetRecipients(RecipientType::cc, CCEmail);
    
  • julkifli33julkifli33 Member Posts: 1,092
    hi @BertVerb ,
    but seems doesnt sent to cc email

    here is my code
    EmailMessage.Create(ToAddress, EmailSubject, BodyTextEmail, true);
    EmailMessage.GetRecipients(RecipientType::Cc, CCEmail);
    Email.Send(EmailMessage, Enum::"Email Scenario"::Default);
    
  • BertVerbBertVerb Member Posts: 24
    @julkifli33 you use GetRecipients.
    You must use AddRecipient
  • julkifli33julkifli33 Member Posts: 1,092
    Hi @BertVerb ,
    where can i find this Addrecipient?

    I only can find GetRecipient
  • BertVerbBertVerb Member Posts: 24
    Which version of BC are you at?
    I can see in BC20 you have Addreciepient in codeunit codeunit 8904 "Email Message":
    https://github.com/microsoft/ALAppExtensions/blob/main/Modules/System/Email/src/Message/EmailMessage.Codeunit.al
  • ftorneroftornero Member Posts: 524
    Answer ✓
    Hello @julkifli33,

    You can use EmailMessage.Create with this signature and pass the CC or BC that you want
        /// <summary>
        /// Creates the email with recipients, subject, and body.
        /// </summary>
        /// <param name="ToRecipients">The recipient(s) of the email. A list of email addresses the email will be send directly to.</param>
        /// <param name="Subject">The subject of the email.</param>
        /// <param name="Body">The body of the email.</param>
        /// <param name="HtmlFormatted">Whether the body is HTML formatted.</param>
        /// <param name="CCRecipients">The CC recipient(s) of the email. A list of email addresses that will be listed as CC.</param>
        /// <param name="BCCRecipients">TThe BCC recipient(s) of the email. A list of email addresses that will be listed as BCC.</param>
        procedure Create(ToRecipients: List of [Text]; Subject: Text; Body: Text; HtmlFormatted: Boolean; CCRecipients: List of [Text]; BCCRecipients: List of [Text])
        begin
            EmailMessageImpl.Create(ToRecipients, Subject, Body, HtmlFormatted, CCRecipients, BCCRecipients);
        end;
    

    Regards
  • julkifli33julkifli33 Member Posts: 1,092
    hi @BertVerb
    I am using version 19.5

    Hi @ftornero ,
    it works !
    thank you much !
Sign In or Register to comment.