Translate

Sunday, May 3, 2015

SSRS send report as attachment in email using Batch

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:

public void quickSend(str fromAddr, str toAddr, str subject, 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();

}

8 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hi,

    accounts receivable > reports > external > customer account statement.

    when i open this report and select account number and click okay,

    the generated report must be send as email in PDF format to the customer email address.

    Thanks in Advance,

    ReplyDelete
  4. Hi buddy,

    I cant understand ur code as u always use this. , what is this has? what are the code you used in the method where you used this. ??

    ReplyDelete
  5. The details of the RRB ALP (Asst. Loco Pilot) Recruitment Notification and the online application will be uploaded to all the 21 RRB Official websites. The online application was started on 3rd Feb 2018 which has now been changed to 28th Feb 2018 and the Last date of filling the RRB ALP online Application form is 31st March 2018 (23:59 hrs).

    ReplyDelete
  6. Government Jobs offer an opportunity to turn your aspirations into reality. If you aspire to work in the mainstream and be a part of the nation's economic development, a job in the Government Sector may be the best option for you. Every year a number of job opportunities become available in the Government Sector.
    For more details - sarkarijob.ind.in
    The UP Police Admit Card 2018 will be released on the official website of the Uttar Pradesh Police Recruitment and Promotion Board (UPPRPB) prpb.gov.in.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. awesome post...! thanks for sharing....postal recruitment 2020 is a postal service that provides high-quality mail, parcel and other related services

    ReplyDelete