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
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
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;
Hi,
The function SMTPMail.AddAttachment is the method you can use to attach the file. If you are facing any error please specify. Thanks
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);
Hi Zaid
I need to attach the report in SMTP mail please give any suggesstion.
Thank You
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
Hi,
Please have a look at the following links and then let me know if you would still have any question. Thanks
How to apply filters to a report:
https://dynamicsuser.net/nav/f/developers/10566/passing-filter-to-a-report
https://community.dynamics.com/nav/f/34/t/147548
https://nav-magno.be/2015/06/printing-pdf-reports-in-classic-without-external-components/
How to send attachment using SMTP:
https://community.dynamics.com/nav/b/arounddynamicsnavworld/archive/2017/02/08/how-to-print-reports-to-pdf-and-send-email
https://community.dynamics.com/nav/b/technicaltipsandtricksfordynamicsnav/archive/2015/07/31/creating-file-attachment-to-mail-for-report
André Arnaud de Cal... 291,391 Super User 2024 Season 2
Martin Dráb 230,445 Most Valuable Professional
nmaenpaa 101,156