I am having problems retrieving the sender of an email in Outlook 2010 - in some cases.
at the moment I am using the following code - courtesy of BlueDevilFan (see
) to get the address back:
Function GetSMTPAddress(olkMsg As Outlook.MailItem) As String
Dim olkSnd As Outlook.AddressEntry, olkExu As Outlook.ExchangeUser
Set olkSnd = olkMsg.Sender
e = olExchangeUserAddressEntry
Set olkExu = olkSnd.GetExchangeUser
GetSMTPAddress = olkExu.PrimarySmtpAddress
GetSMTPAddress = olkMsg.SenderEmailAddress
Set olkSnd = Nothing
Set olkExu = Nothing
However, there are some cases (just 2 cases out of 75 in my initial testing) where this just returns an empty string.
On stepping through the code, the cases are both ones where the AddressEntryUser Type equals
(i.e. the lines in bold get executed).
Can anyone out there explain why this happens and how to get the proper SMTP address back, as opposed to the X400 Exchange address? Or is it just that the sending Exchange server has been badly configured?
Thanks in advance.