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 :

How to customize customer/Sales order invoice email body and subject in Dynamics 365 F&O X++

Rahul Kiran Profile Picture Rahul Kiran 481
In this post I'm going to show you how to send customer invoices with custom email subject and body .

For that I created below class to extend  SrsReportRunPrinter. I'm adding invoice ID in the subjects and using HTML for subject. Change according to your requirement.

[ExtensionOf(classStr(SrsReportRunPrinter))]
final class Class_SrsReportRunMailer_Extension
{
public void printReport()
    {
        SrsReportDataContract contract = reportContract;

        if(contract && SRSPrintMediumType::Email && contract.parmRdpContract() as salesInvoiceContract)
        {
            salesInvoiceContract salesInvoiceContract;
            CustInvoiceJour custInvoiceJour;
            ;

            salesInvoiceContract  = contract.parmRdpContract();
           
            str InvoiceId = CustInvoiceJour::findRecId(salesInvoiceContract.parmRecordId()).InvoiceId;
           
            SRSPrintDestinationSettings     printSettings = contract.parmPrintSettings();

            SrsReportEMailDataContract emailContract = printSettings.parmEMailContract();
           
            printSettings.fileName("Invoice #"+InvoiceId);
           
            str parmSubject = emailContract.parmSubject();

            emailContract.parmSubject(parmSubject +"  " +"#"+InvoiceId);

            str body;

            body = "<html><body>"+ strfmt("Dear Customer,")+ "<br/><br>"+
                strfmt("Please find your invoice attached.") + "<br/><br>"+
                strfmt("Regards,")+ "<br/>"+
                strfmt("Test Team")+ "<br/><br>";
           
            emailContract.parmBody(body);

            //contract.parmPrintSettings().emailSubject(body);
        }
       
        next printReport();

    }

}

That's it. You can contact me for any additional questions.

@Rahul


This was originally posted here.

Comments

*This post is locked for comments