Hi!
I've spent several days on trying to figure out how the "SentOnBehalfOfName" works in automation OSendMail in Codeunit 397. It work as expected when used in combination with "OpenDialog" := TRUE. So I assume, when opening the e-mail before sending, there is some sort of validation or saving that is triggered by outlook. I've been reading on outlookcode.com that if you use the "Save" command it would be validated against MAPI, but in 'NS Outlook Synchronization Handler'.OSendMail there is no "Save" method.
I've also been trying to add the Recipients and Recipient automation instead of using the To,CC,BCC properties, but the "StatusType" doesn't correspond to normal type definition it seems to.
ORecipients := OSendMail.Recipients();
ORecipient := ORecipients.Add(tFrom);
ORecipient.Resolve();
ORecipient.StatusType := 0;
//0 = SenderOrigin (From)
//1 = To
//2 = CC
//3 = BCC
StatusType := 0 doesn't work, but 1,2,3 does.
The scenario is that our customer want's to send all invoices as PDF attachment from the different users PC, but the e-mail should be sent from
invoice@mycompany.com
Has anyone solved this, without having to use "OpenDialog" := TRUE ?
Any help is appreciated.
Comments
In version 5, NAV introduced codeunit 400 which provides much more flexibility, including being able to specifiy the FROM email address.
http://mibuso.com/blogs/davidmachanick/
After that, it remembered the from address and I took out the code to have the email pop up. This method has worked very reliably for a release 4 customer I support.
I also had the users install a free program to eliminate the Outlook warning message - I forget the name - if you need it you can search Mibuso.
http://mibuso.com/blogs/davidmachanick/
It could be some Outlook security or Office issues, even though I've tried on different computers with Outlook 2003 and 2007. But as long as I bring up the e-mail and show it to the user so the user can push the send button, the correct "From" address is filled in when using "SentOnBehalfOfName", but as I said when I'm not bringing up the email (Using "Opendialog = FALSE" in Codeunit 397) the e-mail is beeing sent with the windows logged in user account on that computer.
So please, still need suggestions ](*,)
I am not sure if you can do with NS Outlook Synchronization Handler automation. I think Outlook object library automation has more properties and methods you can use for this issue. (save as etc)
Pargesoft