Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

How To send report with filters in mail attachment

Posted on by 305

Hi  Friends,

How to send a mail in nav with report attachment with report filters in nav 2016.

Thank You

*This post is locked for comments

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: How To send report with filters in mail attachment

    To add the attachement to the email you need to use the AddAttachment Function. For example check the below code for the

    Where Invoice is the Report

                                     Invoice.USEREQUESTPAGE(FALSE);

                                     IF Invoice.SAVEASPDF(FileName) THEN BEGIN

                                       SMTPMail.CreateMessage(

                                         CompanyInformation.Name,

                                         CompanyInformation."E-Mail",

                                         Cust."E-Mail",

                                         STRSUBSTNO('%1 %2.pdf',TABLECAPTION,"No."),

                                         Text003,

                                         TRUE);

                                       SMTPMail.AddAttachment(FileName);

                                       SMTPMail.Send;

                                     END;

  • Suggested answer
    Zaid Tariq Profile Picture
    Zaid Tariq 2,266 on at
    RE: How To send report with filters in mail attachment

    Hi,
    The function SMTPMail.AddAttachment is the method you can use to attach the file. If you are facing any error please specify. Thanks

  • manish.yadav Profile Picture
    manish.yadav 1,835 on at
    RE: How To send report with filters in mail attachment

    Hello Dear,

    I have customised my below code, I am using this for send the pdf with attachments. Hope it will help you.

    PdfDocPath :='ABC.pdf';

    Path := 'C:\Temp\'+PdfDocPath; // Directory + Path

    CLEAR(ABC); // ABC is a Report 50088

    ABC.USEREQUESTPAGE(FALSE);           //// for filteration

    IF NOT ABC.SAVEASPDF(Path) THEN

    ERROR('PDF Creating Failed!\\ERROR:\\' + GETLASTERRORTEXT);

    SMTpMail.CreateMessage('Company Limited','NAV@ITC.com','','Subject Line','',TRUE);

    SMTpMail.AppendBody('Dear Sir / Madam,');

    SMTpMail.AppendBody('<br><br>');

    SMTpMail.AppendBody('Please find the Ledger Details in PDF Format:');

    SMTpMail.AppendBody('<br><br>');

    SMTpMail.AppendBody('Regards');

    SMTpMail.AppendBody('<br>');

    SMTpMail.AppendBody('Company Accounts Departments ');

    SMTpMail.AddAttachment(Path,PdfDocPath);

    SMTpMail.Send;

    ERASE(Path);

  • Prabakaran.R Profile Picture
    Prabakaran.R 305 on at
    RE: How To send report with filters in mail attachment

    Hi Zaid

    I need to attach the report in SMTP mail please give any suggesstion.

    Thank You

  • Prabakaran.R Profile Picture
    Prabakaran.R 305 on at
    RE: How To send report with filters in mail attachment

    Hi Zaid

    thank you reply

    i have used this code in separate code unit and called in page action

    Customer.RESET;

    //Customer.SETRANGE(PDF Generated', FALSE);

    IF Customer.FINDSET THEN BEGIN

    REPEAT

    Filename:= Customer."No.";

    REPORT.SAVEASPDF(59996, Filename, Customer); //PDF CREATED BY SAVEAS FUNCTION

    UNTIL Customer.NEXT = 0;

    END;

    Subject := 'SUBJECT SAMPLE TEXT' ;

    Body := 'BODY SAMPLETEXT';

    SMTP.CreateMessage(SMTPmailsetup."Email Sendor Name",SMTPmailsetup."Email Sendor Emil",

                             Customer."E-Mail",'Customer Email','',TRUE);

    Body := Body +  'OTHER';

    SMTP.AppendBody(Body);

    SMTP.Send;

    MESSAGE('Mail Sended');

    its loading only i did nt get any solution.

    Thank You

  • Suggested answer
    Zaid Tariq Profile Picture
    Zaid Tariq 2,266 on at

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans