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:
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?
Answers
http://ssdynamics.co.in
http://msdn.microsoft.com/en-us/library/dd338921.aspx
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.
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,
Reedberg