If you are on release 5, you should look at using codeunit 400 instead of 397. It provides more flexibility.
If you want to send a pdf copy of the invoice, then you have to print the invoice to a pdf then attach it to the email.
I would make the emailing a separate process. Waiting on sending email will slow down posting.
Write another processing report that will mark the posted document and then email the notification.
Ahmed Rashed Amini
Independent Consultant/Developer
//SalesPost.RUN(SalesHeader);
IF Ship THEN BEGIN
if SalesPost.RUN(SalesHeader) THEN
EmailCust(SalesHeader);
END ELSE
SalesPost.RUN(SalesHeader);
******
You need to add a function to codeunit 81 EmailCust. It would use the Mail codeunit 397.
It would be something like:
Cust.GET(SalesHeader."Sell-To Customer No.");
IF Cust."E-Mail" <> '' THEN BEGIN
BodyText := 'Whatever you want to say, perhaps include sales order no.';
Mail.NewMessage(ECust."E-Mail" ,'',You Order has shipped',BodyText,'',FALSE);
END;
END;
I followed your idea. At the same time I keep in mind ara3n advice. In this scenario, I need some more help on
1. How can I default From Address (irrespective of user)?
2. How to add signature in outlook body (default)?
Hi All,
I have the same question as to how can I define the Email From address(irrespective of user) using MAIL codeunit?
Working in NAV 4 (SP3) native database.
you need codeunit 400 to specify the from address. If your license includes release 5, then export codeinit 400 from a release 5 datebase and import it into your release 4.
I've had great success with a product called ANSMTP from http://www.emailarchitect.net. This company has email libraries for ActiveX/COM/.NET/etc for both SMTP and POP applications. I do not have a lot of experience with developing ActiveX/.NET apps (strictly a C/Side guy), but I was able to build some very sophisticated email capabilities into NAV. I also built an email template form where the users could type in a template for an email message, giving them the ability to modify the text of the message easily.
ANSMTP has access to every field in an email, e.g. "From Address", "To Address" "cc address", "subject", "body", etc. The documentation is excellent and their website has dozens of examples in VB, VBA, .NET, etc. Their email support is very responsive, and the package is only $150 for a single developer (multiple clients), and you can download and use any of their libraries for 30 days for free.
Comments
//SalesPost.RUN(SalesHeader);
IF Ship THEN BEGIN
if SalesPost.RUN(SalesHeader) THEN
EmailCust(SalesHeader);
END ELSE
SalesPost.RUN(SalesHeader);
******
You need to add a function to codeunit 81 EmailCust. It would use the Mail codeunit 397.
It would be something like:
Cust.GET(SalesHeader."Sell-To Customer No.");
IF Cust."E-Mail" <> '' THEN BEGIN
BodyText := 'Whatever you want to say, perhaps include sales order no.';
Mail.NewMessage(ECust."E-Mail" ,'',You Order has shipped',BodyText,'',FALSE);
END;
END;
If you want to send a pdf copy of the invoice, then you have to print the invoice to a pdf then attach it to the email.
http://mibuso.com/blogs/davidmachanick/
Write another processing report that will mark the posted document and then email the notification.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I followed your idea. At the same time I keep in mind ara3n advice. In this scenario, I need some more help on
1. How can I default From Address (irrespective of user)?
2. How to add signature in outlook body (default)?
I have the same question as to how can I define the Email From address(irrespective of user) using MAIL codeunit?
Working in NAV 4 (SP3) native database.
http://mibuso.com/blogs/davidmachanick/
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
ANSMTP has access to every field in an email, e.g. "From Address", "To Address" "cc address", "subject", "body", etc. The documentation is excellent and their website has dozens of examples in VB, VBA, .NET, etc. Their email support is very responsive, and the package is only $150 for a single developer (multiple clients), and you can download and use any of their libraries for 30 days for free.
Regards,
Ron
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n