Codeunit 397 Mail - OSendMail.SentOnBehalfOfName

MrWhoMrWho 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.
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

  • davmac1davmac1 Member Posts: 1,283
    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.
  • MrWhoMrWho Member Posts: 59
    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.
  • MrWhoMrWho Member Posts: 59
    Bad luck. Technical department wouldn't open for SMTP traffic. So I'm back to same problem.
  • davmac1davmac1 Member Posts: 1,283
    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.
  • MrWhoMrWho Member Posts: 59
    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 ](*,)
  • ufukufuk Member Posts: 514
    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
    Pargesoft
Sign In or Register to comment.