Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

How to send E-mail to customer when sales order is created

Posted on by Microsoft Employee

I have created a sales order and fill up the header & line information. I have created a page action "Send E-mail" in Sales Order Page. So when I click the "Send E-mail" button, the mail will be automatically be send to the particular customer with Sales Order No. & Line Details.

The Customer Mail Id wil be taken from Customer Card and Sender's mail id will be from Company Information.

Body of the mail will be fixed format, only the Sales Order No. & Line Details will vary.

Eg.: Dear Customer Name,

A Sales Order has been booked under Sales Order No. - Sales Order No. with items as follows.

Item Code1    Item Name      Quantity      Amount

Item Code2    Item Name      Quantity      Amount

Kindly help me how to proceed as I don't know about mailing process.

Thanks in advance.

*This post is locked for comments

  • Verified answer
    TharangaC Profile Picture
    TharangaC 23,116 on at
    RE: How to send E-mail to customer when sales order is created

    It is always better to use the SMTP setup for sending the e-mails. Therefore first fill the SMTP setup with related information and check the setup is working with "Test Email Setup". If you receive the e-mail then the setup is working fine and you are ready to move to next step.

    Email.PNG

    Step 02 :  If you are using Dynamics NAV 2016 you will have the option of sending the order confirmation to the customer by email. If you are not happy with the function and need to have a fix body then you can modify the code.

    Email.PNG

    To modify the code check the codeunit 229  ("Document-Print") and in that function "DoPrintSalesHeader".

    IF SendAsEmail THEN BEGIN
          AttachmentFilePath := SaveSalesHeaderReportAsPdf(SalesHeader,ReportSelections."Report ID");
          DocumentMailing.EmailFileFromSalesHeader(SalesHeader,AttachmentFilePath,CustomReportSelection);
        END ELSE


    Also check the function "EmailFile" where the mail get generate

    IF AttachmentFileName = '' THEN
      AttachmentFileName := STRSUBSTNO(ReportAsPdfFileNameMsg,EmailDocName,PostedDocNo);
    CompanyInformation.GET;
    WITH TempEmailItem DO BEGIN
      IF CustomReportSelection."Send To Email" <> '' THEN
        "Send to" := CustomReportSelection."Send To Email"
      ELSE
        "Send to" := GetToAddressFromCustomer(SendEmaillToCustNo);
      Subject := COPYSTR(
          STRSUBSTNO(
            EmailSubjectCapTxt,CompanyInformation.Name,EmailDocName,PostedDocNo),1,
          MAXSTRLEN(Subject));
      "Attachment File Path" := AttachmentFilePath;
      "Attachment Name" := AttachmentFileName;
      Send(HideDialog);
    END;


    In here you need to add the body of you like.

  • Verified answer
    Alexander Ermakov Profile Picture
    Alexander Ermakov 28,094 on at
    RE: How to send E-mail to customer when sales order is created

    Please refer to this how-to: msdn.microsoft.com/.../dn789545(v=nav.90).aspx

  • IshwarSharma Profile Picture
    IshwarSharma 729 on at
    RE: How to send E-mail to customer when sales order is created

    Please check this post. ishwar-nav.blogspot.in/.../send-mail-with-pdf-attachment-in-nav.html

  • Verified answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on at
  • Suggested answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: How to send E-mail to customer when sales order is created

    Hello,

    Write something like.

    if you need more looking good then use HTML Table tag

    // Better to get sender details from SMTPMailSetup Table.

    // You have to configure SMTP Mail Setup first.

    //>>EmailCode
    SMTPMailSetup.GET;
    IF CompanyInformation.GET THEN
     SenderName := CompanyInformation.Name;

    IF Cust.GET("Sell-to Customer No.") THEN
     ToAddress := Cust."E-Mail";

    SalesLineL.SETRANGE("Document No.","No.");
    IF SalesLineL.FINDSET THEN BEGIN
     SMTPMail.CreateMessage('SenderName','Sender Address','ToAddress','Subject','Body',TRUE);
     SMTPMail.AppendBody('Dear '+"Sell-to Customer Name");
     SMTPMail.AppendBody('<Br>');
     SMTPMail.AppendBody(STRSUBSTNO('A Sales Order has been booked under Sales Order No. - %1 with items as follows.',"No."));
     SMTPMail.AppendBody('<Br>');
       REPEAT
         SMTPMail.AppendBody(SalesLineL."No." +' '+FORMAT(SalesLineL.Quantity)+'            '+FORMAT(SalesLineL.Amount));
         SMTPMail.AppendBody('<Br>');
       UNTIL SalesLineL.NEXT = 0;
       SMTPMail.Send;
    END;

    //<<EmailCode

    Variables Need:

    Name          DataType    Subtype  Length
    SalesLineL    Record       Sales Line
    SMTPMail   Codeunit      SMTP Mail
    Cust           Record         Customer
    CompanyInformation     Record       Company Information
    ToAddress         Text
    SenderName     Text
    SenderAddress  Text
    SMTPMailSetup Record        SMTP Mail Setup

  • Verified answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: How to send E-mail to customer when sales order is created

    Check following discussion on forum

    community.dynamics.com/.../144239

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans