Saturday, October 13, 2018

NAV - how to send a report as an email attachment on a schedule

https://saurav-nav.blogspot.com/2013/08/send-mail-with-attachment-from-navision.html



Create codeunit to save report to pdf
Create another to call smtpmail function and attach pdf and send

------------------------------------------


SendStmtPostErrMail(Title : Text;Message : Text[250])
SMTPSetup.GET;
Contact.SETFILTER("No.",'CT010001');
Contact.FINDFIRST;
Contact.TESTFIELD("E-Mail");

SMTPMail.CreateMessage(SMTPSetup."User ID",SMTPSetup."User ID",Contact."E-Mail",Title,'',TRUE);
SMTPMail.AddCC('mail@gmail.com');
SMTPMail.AppendBody(Message);


SMTPMail.Send;

SendTestEmail()
SendStmtPostErrMail('Title-Statement Post Error','Body-Review and post statements manually');

No comments:

Post a Comment