Hello
I am new to nav so please suggest some answers for how to send email to users after posting the purchase invoice
Thanks in advance
Hello
I am new to nav so please suggest some answers for how to send email to users after posting the purchase invoice
Thanks in advance
I got the answer and thanks for your help
First of all,
if you want to add some text you shall rather change MailBody. Please see what arguments CreateMessage method gets.
Additionally I don't see where you want to add attachment to the mail.
Have you debugged that code ?
Regards
Sure
SMTPSetup.GET;
SenderMail := SMTPSetup."User ID";
MailBody += '<br><br>';
MailBody := MailBody + 'Best Regards' + '<br>';
MailBody := MailBody + FORMAT(USERID) + '<br>';
MailBody := MailBody + FORMAT(COMPANYNAME) + '<br>';
MailBody := MailBody + '_____' + '<br><br><br>';
MailBody := MailBody + 'This message was created automatically.' + '<br>';
rec_purchinv.RESET;
rec_purchinv.SETRANGE("No.",PurchInvHeader."No.");
IF rec_purchinv.FINDLAST THEN
REPORT.SAVEASPDF(406,'E:\Purchase Invoices\Purchaseinvoice.pdf',rec_purchinv);
SMAIL.CreateMessage('guru','xxr@gmail.com','MM@gmail.com','Report',MailBody,TRUE,'Purchase Invoice','Dear Yog Please find the attached Purchase Invoice Document FOR your ref','test');
SMAIL.AddCC('XX.com');
SMAIL.Send;
Could you please show the code ?
Thanks for you are update , i follow the instruction which was given by you and now i am getting a dot net error, and i just mentioned below
A DotNet variable has not been instantiated. Attempting to call Microsoft.Dynamics.Nav.SMTP.SmtpMessage.AddAttachment in CodeUnit Purch.-Post: SMTPMail
Hey,
I see two options,
the first requires the recipient has NAV client. If yes you can create a link in mail using html and links docs.microsoft.com/.../creating-and-running-hyperlinks
after that the recipient is able to open report directly from mail.
the second relies on creating a file from report like PDF and then you can use method SMAIL.addAttachment and send the report as a file.
I getting the email but the report for the particular purchase invoice is not showing how to attach the invoice report
Hey,
the author of the post probably created some action on page to post the invoice. Therefore you can create the method in the page and on that action simply call method [SendMail] to run the code. There is no codeunit necessary :)
In which codeunit i want to write this codes is this code unit under 400 or something else
I use to send mails using that steps
1. Create variables
2.Create parameters
3. Create method
SendMail(MailTitle : Text;MailBody : Text;EmployeeEmail : Text) SMTPSetup.GET; SenderMail := SMTPSetup."User ID"; //Default mail account // Compose the message ------------------------------- MailBody = '
'; MailBody := MailBody 'Best Regards' '
'; MailBody := MailBody FORMAT(USERID) '
'; MailBody := MailBody FORMAT(COMPANYNAME) '
'; MailBody := MailBody '______' '
'; MailBody := MailBody 'This message was created automatically.' '
'; //send the message SMAIL.CreateMessage('nameofsender', SenderMail, EmployeeEmail, MailTitle, MailBody, TRUE); SMAIL.AddCC('mail@mail.com'); SMAIL.Send;
and after the method is coded you can simply add the method to some action that post your invoices and do some logic arround.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,558 Super User 2024 Season 2
Martin Dráb 228,645 Most Valuable Professional
nmaenpaa 101,148