AX2009 Report export to outlook express.

Hi Guys.

I have a requirement to attach a axapta report with outlook express.

i.e.

I have a purchase order form and i made a button EMAIL. What i need is that when i click this button it should open the outlook express and attach the Purchase order report .pdf with this email message.

Please guys if you have any thing like this i will be very thankful any idea or link how to achieve this requirement.

Thanks.

Hi Kami,

You can take help from the below code and put the modified code in the click event of Email button

  1. Create PrintJobSetting object and set the properties as below

printJobSettings.setTarget(PrintMedium::Mail);
printJobSettings.format(PrintFormat::PDF);
printJobSettings.fileName(fileName);

  1. Run your report through code like i run the sales invoice report.

salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice, false);
salesFormLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());
args.record(_custInvoiceJour);
args.caller(salesFormLetter);
new MenuFunction(menuitemoutputstr(SalesInvoice), MenuItemType::Output).run(args);

After executing the run method system will open the outlook with the pdf report as an attachement.

I hope it will work for you.

Regards,

Zeeans

Hi Zeeshan,

I have found the following code and it is working but the problem is there are 2 issues i am facing can you please help me on these

When i click the button it gives the print dialog box selecting the E-mail recipient option as the default. Then when i click OK i get the warning window from Outlook saying “A program is trying to access e-mail address you have …” How to stop this window to display. After i select YES it directly send the email i want to it be opened in the outlook to write the text for the email body.

void clicked()
{
Args aa = new Args(“TestReport”);
ReportRun rn = new ReportRun(aa);
;

rn.printJobSettings().setTarget(PrintMedium::Mail);
rn.printJobSettings().Format(PrintFormat::PDF);
rn.printJobSettings().mailTo(“tets@yahoo.com”);
rn.printJobSettings().mailSubject(“test subject”);

rn.run();
super();
}