PDA

View Full Version : [SOLVED:] Getting sender's email (or name) on Application_ItemSend



chaeska
07-10-2014, 07:46 AM
Hi all!

I have the following problem: I have multiple accounts configured in Outlook and I sometimes accidentally send messages from the wrong one just by virtue of having a folder selected upon writing a new mail.

I'd like to e.g. display a message box before sending mails from the wrong account.

I found a macro for checking the receipient's address and acting accordingly but it doesn't quite do what I want since it's the FROM field that interests me.

The accounts are NOT Exchange accounts, they are IMAP accounts, so I cannot use the getExchangeUser method. I also read somewhere that the SenderEmailAddress property is not set before the mail is actually sent.

The only thing I need to know, basically, is how I return the "from" field value in an unsent message. The rest I can code myself. :)

Cheers!

westconn1
07-10-2014, 02:27 PM
you can try one of the properties of the current user
like
msg.getinspector.Session.CurrentUser.Name

skatonni
07-10-2014, 04:24 PM
You could try SendUsingAccount

http://msdn.microsoft.com/en-us/libr...ffice.15).aspx (http://msdn.microsoft.com/en-us/library/office/ff869311(v=office.15).aspx)


Sub senderAccount()
Dim msg As mailItem
Set msg = Application.ActiveInspector.currentItem
MsgBox msg.SendUsingAccount ' Breaks on a form
End Sub

chaeska
07-11-2014, 12:20 AM
Thanks westconn1 and skatonni!

I tried using msg.getinspector.Session.CurrentUser.Name, sadly it always returns the same (set in Office) value since it takes the Outlook session regardless of the current message.

SendUsingAccount is EXACTLY what I needed. Thanks a bunch. :)