Codeunit 397 Mail - OSendMail.SentOnBehalfOfName
MrWho
Member Posts: 59
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.
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.
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.
0
Comments
-
What NAV version is you customer licensed for?
In version 5, NAV introduced codeunit 400 which provides much more flexibility, including being able to specifiy the FROM email address.David Machanick
http://mibuso.com/blogs/davidmachanick/0 -
Thank you very much for opening my eyes. We've just upgraded the customer from 3.7 to 5.0 SP1 so this couldn't be timed better I hope. I'll have a look at it and see if I can make it work. I'm currently waiting on correct SMTP-Server address from the technical department since this needed to be setup first in SMTP Mail Setup table. I'll post back on how it went.0
-
Bad luck. Technical department wouldn't open for SMTP traffic. So I'm back to same problem.0
-
I solved the problem with codeunit 397 by having the code bring up the email, then having the user populate the from address and send it.
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.David Machanick
http://mibuso.com/blogs/davidmachanick/0 -
Thanks for trying to help out, but in 5.0 SP1 this seems to not work.
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 ](*,)0 -
I tried as you said and noticed that after waiting a while outlook changes the sender with the original mail account. (may be something related with delegation setup??)
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)Ufuk Asci
Pargesoft0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions