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
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.
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.
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.
Please refer to this how-to: msdn.microsoft.com/.../dn789545(v=nav.90).aspx
Please check this post. ishwar-nav.blogspot.in/.../send-mail-with-pdf-attachment-in-nav.html
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
Check following discussion on forum
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156