You don't need to use SMTP. Just setup Document Approval in NAV it will do which you want to implement
and if you don't want to do that, then you can customize it.
The algorithm will be like that.
1. When the purchase order has been created (inserted) on that even you get the newly created purchase order and send a notification email via SMTP.
2. If you want to include direct link you have to see how WebClient of Dynamics NAV and you need to form appropriate URL and embed it in the email body.
SMTP takes minimum 1 day to notify the approval record. Here user wants immediate notification.
SMTP in general will send emails immediately. Approval notifications uses Notification Templates and Notification Schedule to format, schedule and send emails (via SMTP). You need to make sure that the "Recurrence" field is set to "Instantly" on the Notification Schedule. Have a look at this for more info...
Since SMTP was not working from my server, I am using email code unit to send emails.
Warm regards
Kris
SMTP was probably not working on the server because the SMTP server setup was incorrect (e.g. "Secure Connection" / Port etc... as mentioned by others). Once you have the SMTP working it would probably be better to use standard Approvals (assuming your requirements haven't changed) otherwise you're really reinventing the wheel. If you are going to do your own approvals then things you may want to consider are...
1) Making sure the email is only sent once the Order has been fully entered (i.e. user has entered all header & line details)
2) Implementing methods to allow the approver (manager/CEO) to actually approve / decline the order
3) Blocking changes to the order once the approvel request/email has been sent.
4) Making sure the document cannot be posted without it being approved first
5) Having a log/audit of who approved the document and when
etc...
For the above reasons and more, I'd suggest you go back to standard approvals once you have your SMTP setup working.
Answers
You can read more about here:
https://msdn.microsoft.com/en-us/library/dd338778(v=nav.90).aspx
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.
Zaid Tariq
Dynamics NAV/365 BC Developer at Dynamics 360
please like / agree / verify my answer, if was helpful.
and if you don't want to do that, then you can customize it.
The algorithm will be like that.
1. When the purchase order has been created (inserted) on that even you get the newly created purchase order and send a notification email via SMTP.
2. If you want to include direct link you have to see how WebClient of Dynamics NAV and you need to form appropriate URL and embed it in the email body.
For the URL generation you can see this link: https://blogs.msdn.microsoft.com/nav/2013/11/04/creating-urls-to-microsoft-dynamics-nav-clients/
5. If your CEO user is configured in Dynamics NAV, when he will click on that link he will be able to see that purchase order and he can approve it.
But i will stay say, implement the Document Approval in Dynamics NAV. Its more efficient and designed for this task.
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.
https://blogs.msdn.microsoft.com/nav/2013/11/04/creating-urls-to-microsoft-dynamics-nav-clients/
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
SMTP in general will send emails immediately. Approval notifications uses Notification Templates and Notification Schedule to format, schedule and send emails (via SMTP). You need to make sure that the "Recurrence" field is set to "Instantly" on the Notification Schedule. Have a look at this for more info...
https://msdn.microsoft.com/en-us/library/dn951588(v=nav.90).aspx
Also make sure that the Job Queue used to process the Notification Queue is set to run on a regular basis (every 5 minutes or whatever you need)
Since SMTP was not working from my server, I am using email code unit to send emails.
Warm regards
Kris
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
You can see my configuration i m able to get the email.
Also you might need to turn on the "Access for less secure apps"
Hope this helps.
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.
use 587 port
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
SMTP was probably not working on the server because the SMTP server setup was incorrect (e.g. "Secure Connection" / Port etc... as mentioned by others). Once you have the SMTP working it would probably be better to use standard Approvals (assuming your requirements haven't changed) otherwise you're really reinventing the wheel. If you are going to do your own approvals then things you may want to consider are...
1) Making sure the email is only sent once the Order has been fully entered (i.e. user has entered all header & line details)
2) Implementing methods to allow the approver (manager/CEO) to actually approve / decline the order
3) Blocking changes to the order once the approvel request/email has been sent.
4) Making sure the document cannot be posted without it being approved first
5) Having a log/audit of who approved the document and when
etc...
For the above reasons and more, I'd suggest you go back to standard approvals once you have your SMTP setup working.
There was wrong entry in email id and password.
SMTP is working fine
Thanks and warm Regards
Kris