Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 64797

SSRS send report as attachment in email using Batch

$
0
0
Hi Folks,

As the standard AX 2012 feature we can schedule any report to send it as attachment on periodic basis. Though standard SysMailerNet class fails if you do not provide any email id in cc. To fix this issue; change the quickSend method of SysMailerNet class as mentioned below:

publicvoidquickSend(str fromAddr, str toAddr, strsubject, str body, str cc='', str attachments='')
{

    SysMailerNetAddressField tos;
    SysMailerNetAddressField ccs;
    SysMailerNetAttachments mailAttachments;
    SysEmailParameters parameters;

    List emailAddresses;
    ListEnumerator enum;
    ;

    this.fromAddress(fromAddr);

    tos = this.tos();
    emailAddresses = SysEmailDistributor::splitEmail(toAddr);
    enum = emailAddresses.getEnumerator();
    while(enum.moveNext())
    {
        tos.add(enum.current());
    }

    this.subject(subject);
    this.htmlBody(body);

    //USR-Start
    ccs = this.ccs();
    emailAddresses = SysEmailDistributor::splitEmail(cc);
    enum = emailAddresses.getEnumerator();
    while(enum.moveNext())
    {
        ccs.add(enum.current());
    }

    /*if (!prmisDefault(cc))
    {
        ccs = this.ccs();
        ccs.add(cc);
    }*/
    //USR-End

    if (!prmisDefault(attachments))
    {
        mailAttachments = this.attachments();
        mailAttachments.add(attachments);
    }

    this.priority(System.Net.Mail.MailPriority::Normal);

    parameters = SysEmailParameters::find();

    if (parameters.smtpRelayServerName)
    {
        this.smtpRelayServer(parameters.smtpRelayServerName,parameters.smtpPortNumber,parameters.smtpUserName,SysEmailParameters::password(),parameters.ntlm);
    }

    this.sendMail();

}


Viewing all articles
Browse latest Browse all 64797

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>