web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

How To send report with filters in mail attachment

(0) ShareShare
ReportReport
Posted on by 313

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

I have the same question (0)
  • Suggested answer
    Zaid Tariq Profile Picture
    2,274 on at
  • Prabakaran.R Profile Picture
    313 on at

    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

  • Prabakaran.R Profile Picture
    313 on at

    Hi Zaid

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

    Thank You

  • manish.yadav Profile Picture
    1,893 on at

    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);

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

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

  • Suggested answer
    Suresh Kulla Profile Picture
    50,269 Super User 2026 Season 1 on at

    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;

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans