AX 2012 - How to send SSRS report in email as an attachment using X++
Hi Technical,
Today, in this post we will share, how you can send SSRS report in email as an attachment using X++. Please find the below code...
Comment below if you find this article helpful...
Author:
Chirag Gupta
Microsoft Dynamics 365 AX Technical Consultant at IBM Bangalore
Date:
17-Sep-2019
Happy Learning !!
Today, in this post we will share, how you can send SSRS report in email as an attachment using X++. Please find the below code...
// Created by: Chirag Gupta
// Created date: 17-Sep-19
// Summary: Send SSRS Report in excel format as attachment in email.
public void EmailSSRSReport(Args _args)
{
SrsReportRunController controller = new SrsReportRunController();
SRSPrintDestinationSettings printSettings;
SrsReportEMailDataContract emailContract;
// set report name
controller.parmReportName(ssrsReportStr(RMPMBPRReport, Report));
// create email contract
emailContract = new SrsReportEMailDataContract();
// fill in the email contract details
emailContract.parmAttachmentFileFormat(SRSReportFileFormat::Excel);
emailContract.parmSubject("RMPM BPR Report " + strUpr(curext()));
emailContract.parmBody("Dear Customer, Please find attachment.");
emailContract.parmTo("axwithchirag@gmail.com");
emailContract.parmCc("chirag.gupta0123@gmail.com");
// get print settings from contract
printSettings = controller.parmReportContract().parmPrintSettings();
// update print settings with email contract and use Excel format in the attachment
printSettings.printMediumType(SRSPrintMediumType::Email);
printSettings.parmEMailContract(emailContract);
printSettings.fileFormat(SRSReportFileFormat::Excel);
// Suppress the parameter dialog
controller.parmShowDialog(false);
// start operation
controller.startOperation();
info("Report mailed successfully.");
}
// Created date: 17-Sep-19
// Summary: Send SSRS Report in excel format as attachment in email.
public void EmailSSRSReport(Args _args)
{
SrsReportRunController controller = new SrsReportRunController();
SRSPrintDestinationSettings printSettings;
SrsReportEMailDataContract emailContract;
// set report name
controller.parmReportName(ssrsReportStr(RMPMBPRReport, Report));
// create email contract
emailContract = new SrsReportEMailDataContract();
// fill in the email contract details
emailContract.parmAttachmentFileFormat(SRSReportFileFormat::Excel);
emailContract.parmSubject("RMPM BPR Report " + strUpr(curext()));
emailContract.parmBody("Dear Customer, Please find attachment.");
emailContract.parmTo("axwithchirag@gmail.com");
emailContract.parmCc("chirag.gupta0123@gmail.com");
// get print settings from contract
printSettings = controller.parmReportContract().parmPrintSettings();
// update print settings with email contract and use Excel format in the attachment
printSettings.printMediumType(SRSPrintMediumType::Email);
printSettings.parmEMailContract(emailContract);
printSettings.fileFormat(SRSReportFileFormat::Excel);
// Suppress the parameter dialog
controller.parmShowDialog(false);
// start operation
controller.startOperation();
info("Report mailed successfully.");
}
Comment below if you find this article helpful...
Author:
Chirag Gupta
Microsoft Dynamics 365 AX Technical Consultant at IBM Bangalore
Date:
17-Sep-2019
Happy Learning !!
NfunriVcerpeAlbuquerque Charles Naranjo https://wakelet.com/wake/4H64uAygvMs4HR9OZ01os
ReplyDeleteruncpunccuhan