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 subject and using HTML for body. Change the code 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
For that I created below class to extend SrsReportRunPrinter. I'm adding invoice ID in the subject and using HTML for body. Change the code 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
Really helpful walkthrough! Customizing invoice emails in Dynamics 365 F&O with X++ makes customer communication so much more professional. The example code you shared is clean and easy to tweak. By the way, for anyone managing projects or business sites, having reliable lifetime web hosting can be just as important as streamlining ERP workflows.
ReplyDelete