Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

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

(0) ShareShare
ReportReport
Posted on by

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
    Tharanga Chandrasekara Profile Picture
    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
    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
    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
    6,851 on at
  • Suggested answer
    Binesh Profile Picture
    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
    18,698 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

Announcing the Engage with the Community forum!

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics NAV (Archived)

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2

#1
mmv Profile Picture

mmv 2

#1
Amol Salvi Profile Picture

Amol Salvi 2

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans