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 article is really fantastic and thanks for sharing the valuable post.
    Microsoft Dynamics AX Training | Sharepoint Online Training

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

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

      Delete
  2. 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
  3. 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
  4. 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
  5. 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
  6. JEE Main Counselling Dates: Complete Counselling Procedure - Registration, Filling of Choices,Seat Allotment,Fee Payment, Other Counselling Procedures.

    JEE Main Resuls for Paper 1 and Paper 2 will be declared by the CBSE - Check Here Important Dates And Scheduled Event Related To Jee Main Result 2018, JEE Main 2018 Scorecard, How to calculate Percentile

    SRMJEEE 2018 Admit Card Download: Have you Applied for SRM University then its time to Download SRMJEEE Admit Card

    JKCET 2018 Admit Card is going to be released on April 10. Candidates are advised to download the JKCET Admit Card from the official website.

    KEAM 2018 Admit Card will be released through online mode on 10th April 2018. Candidates are advised to download the KEAM Admit Card from Official Website.

    The admit card will be generated after the completion of the registration process. NATA Admit Card will be released via online mode only.

    ReplyDelete