I have tried using mailItem.SenderEmailAddress
and mailItem.Sender.Address
but they both return a string that looks like this:
/O=DO
Created a VBA function if you wanted to use it for simplicity. A sample call would be
Left(GetEmailAddress(mai) & Space(50), 50)
where mai
is expected to be a MailItem
object. Used and tested successfully in Microsoft Outlook 2010
Public Function GetEmailAddress(mai As Object) As String
On Error Resume Next
Set ObjSelectedItem = mai
If TypeName(ObjSelectedItem) = "MailItem" Then
If ObjSelectedItem.SenderEmailType = "EX" Then
GetEmailAddress = ObjSelectedItem.Sender.GetExchangeUser.PrimarySmtpAddress
Else
GetEmailAddress = ObjSelectedItem.SenderEmailAddress
End If
Else
GetEmailAddress = "Not a MailItem"
End If
Set ObjSelectedItem = Nothing
End Function