none
How to check which account a user is attempting to send an email from, then make some changes RRS feed

  • General discussion

  • I need to check the 'to' field on an email, if it meets certain criteria, I need to check which account they are attempting to use.  If it's not the correct one, either change it, or save the email as a draft in the draft folder so they can try the correct way.  

    It's easy to do the checking of the 'to' field, but I can't get the 'account';

    I've tried     mail.SenderEmailAddress but that is not populated until user hit's send (I think). So I can't tell if they are using

    the coreect account.

    Thursday, May 31, 2012 4:14 PM

All replies

  • Use the MailItem.SendUsingAccount property.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Thursday, May 31, 2012 4:34 PM
  • and invoke your code in Application.ItemSend event - it can be cancelled or you can set proper account there.
    Thursday, May 31, 2012 6:05 PM
  • Cool, the sendusing works.  I can get the 'sendusing' but can't set it.  It seems like it changes it, then before sending the email it gets changed back.  Perhaps the GUI is overriding it, at the very end?

     How can you cancel an email?  Stop doesn't work.  I would like to, if they are using the wrong account, save the email as a draft in the draft folder.  Any Idea how to save it there.  

    Thanks!!!!!!


    • Edited by pdgrimm Friday, June 1, 2012 2:13 AM
    Thursday, May 31, 2012 11:55 PM
  • ItemSend event handler passes the Cancel parameter (by reference). Set it to true.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Friday, June 1, 2012 1:40 AM