E-mail through NAV5: needs clarification
Reedberg
Member Posts: 68
Hello all,
I am a NAV developer. My client uses NAV5. I am working on a project to send e-mail through NAV. For sending e-mail I use codeunit 400. E-mail are send with the help of NAS.
I have several questions which are not clear for me, so any help will be appreciated!
1. I added a timer to the standard NAV codeunit E-Mail Dispatcher (5065). This timer will be run by NAS. Codeunit E-Mail Dispatcher is SingleInstance.
My client already has some integration which is run by NAS. There is a custom codeunit "WMS Integration" which contains timer "WMS Timer". "WMS Timer" calls functions which do some integrations with WMS. Custom Codeunit "WMS Integraion" is not SingleInstance. It works fine.
I am wondering why developers which worked on the project before (they already left) be decided to make "WMS Integration" codeunit not a SingleInstance one. This codeunit is called only from Codeunit 1, from NasHandler function.
May it be the case that NAS has some problems with SingleInstance objects or something like this?
2. I found that similar task was implemented for another customer of my company. I found that following code which was actually sending e-mails:
3. I tried to send with the help of 397 codeunit. This codeunit uses automation with type 'NS Outlook Synchronization Handler'. When I send e-mails through 397 codeunit they remain in the "Send" box in my Outlook client. But the task is to send messages to several recipients.
Does anybody know a way to send e-mail through 397 codeunit to several recipients?
I am a NAV developer. My client uses NAV5. I am working on a project to send e-mail through NAV. For sending e-mail I use codeunit 400. E-mail are send with the help of NAS.
I have several questions which are not clear for me, so any help will be appreciated!
1. I added a timer to the standard NAV codeunit E-Mail Dispatcher (5065). This timer will be run by NAS. Codeunit E-Mail Dispatcher is SingleInstance.
My client already has some integration which is run by NAS. There is a custom codeunit "WMS Integration" which contains timer "WMS Timer". "WMS Timer" calls functions which do some integrations with WMS. Custom Codeunit "WMS Integraion" is not SingleInstance. It works fine.
I am wondering why developers which worked on the project before (they already left) be decided to make "WMS Integration" codeunit not a SingleInstance one. This codeunit is called only from Codeunit 1, from NasHandler function.
May it be the case that NAS has some problems with SingleInstance objects or something like this?
2. I found that similar task was implemented for another customer of my company. I found that following code which was actually sending e-mails:
SmtpMail.CreateMessage("Sender Name", "Sender E-mail", '',Subject,Body,FALSE);
SmtpMail.Send;
COMMIT;
SLEEP(200);
What is SLEEP function designed for? Can I remove it?3. I tried to send with the help of 397 codeunit. This codeunit uses automation with type 'NS Outlook Synchronization Handler'. When I send e-mails through 397 codeunit they remain in the "Send" box in my Outlook client. But the task is to send messages to several recipients.
FOR FileNameCounter := 1 TO ARRAYLEN(CCNames) DO BEGIN
IF CCNames[FileNameCounter] <> '' THEN BEGIN
ORecipients := OSendMail.Recipients;
ORecipient := ORecipients.Add(CCNames[FileNameCounter]);
END;
END;
Method Add works just fine for adding recipients. However when I try to send message I got the error 2699 with now further description. The e-mail is not send, instead it is saved in templates of my Outlook client. I found several posts where people encountered the same issue, but I didn't manage to find a solution.Does anybody know a way to send e-mail through 397 codeunit to several recipients?
0
Answers
-
There are lot of posts on the forum related to email you could try searching them. I though don't use standard NAV method but instead rely on SQL Server database mail. IMHO it is more stable and provides email log feature. Further NAV hangs (sleeps) while the mail is send (that's why sleep command is used) but SQL executes within seconds. The only catch is that it requires SQL server for execution.CA Sandeep Singla
http://ssdynamics.co.in0 -
No, NAS doesn't have any issue with SI codeunits. It's quite the contrary, it needs at least one SI codeunit to run properly. In most cases it's the starting codeunit. This codeunit holds some functionality to start your needed process, either based on timer or based on some external event trigger call.Reedberg wrote:May it be the case that NAS has some problems with SingleInstance objects or something like this?
http://msdn.microsoft.com/en-us/library/dd338921.aspxReedberg wrote:What is SLEEP function designed for? Can I remove it?
In my opinion SLEEP is used in two scenarios. Either you want to make sure that system control is detached from your current function (that way other processes have a chance to do their job in the meantime) or you started some kind of external process and you don't know how long it'll take, so you wait (sleep) for a certain period of time. Both have to be considered very carefully as they indicate that there's maybe something wrong with your solution design."Money is likewise the greatest chance and the greatest scourge of mankind."0 -
Dear ssingla,
Thank you for your reply, my client has a very strong policy regarding production database and SQL-server, even system administrator of the Production DB does not have access to SQL. In order to get such an access there must be special authorization, etc.. So, in my particular case SQL option can not be used.
einsTeIn.NET
Thank you for your reply!
Regards,
Reedberg0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions