Bojensen Blogs

How to send a report via email from Microsoft Dynamics AX

Hi all!

Today I want to show you how to send a custom report via email from AX (it works with an AX client installation and it’s tested for Microsoft Outlook and Novell GroupWise).

In AX there is a class that allows you to do this: “SysINetMail”.

Here’s the code:

void printPDFMail()
    SysINetMail     SysINetMail;
    str             FileName;
    str             user;
    str             Body;
    str             Subject;
    str             cc1;
    str             mailAddressFrom;
    str             mailAddressTo;
    UserInfo        userInfo;
    SysINetMail mail = new SysINetMail();

    select firstonly userInfo where; {
    user= userInfo.networkAlias; }

    FileName = strfmt('C:\\Users\\%1\\Desktop\\AXReportName.pdf',user);


    //assign the values ​​of sender, recipient, subject and message body
    Subject     = 'Insert here the email subject';
    Body        = 'Insert here the email body';
    cc1         = '';

    //assign the values ​​to send email
    mailAddressFrom     = SysUserInfo::find(curUserId()).Email;
    mailAddressTo       =
    //Send Mail
    //delete the temporary pdf file

    //info("Email sent.");




I have included this method in a class that creates the report to be sent, but if you want to use it as a job, you have to use “Args” function to pass the name of the report to be printed.

Posted on

Comments are closed.