PDA

View Full Version : Solved: Fetching SenderEmailAddress



MWE
11-18-2006, 10:10 PM
I am running Outlook2000. I wish to fetch the "sender email address" from a given mail item. I did a search and found a thread suggesting that SenderEmailAddress is a valid property of a mailitem and this is precisely what I want to fetch. Unfortunately, SenderEmailAddress does not appear to be a valid mailitem property with my version of Outlook.:dunno

Thanks

Andy Pope
11-19-2006, 04:36 AM
Would seem that SenderEmailAddress was introduced to the object model in 2003 version.
Sub x()
Dim olApp As Outlook.Application
Dim olNamespace As Outlook.Namespace
Dim olItem As MailItem

Set olApp = CreateObject("Outlook.application")
Set olNamespace = olApp.GetNamespace("Mapi")

For Each olItem In olNamespace.GetDefaultFolder(olFolderInbox).Items
Debug.Print olItem.Subject, olItem.SenderEmailAddress
Next

End Sub

Try using CDO
http://www.cdolive.com/cdo5.htm#GetSenderInformation

MWE
11-19-2006, 11:08 AM
Would seem that SenderEmailAddress was introduced to the object model in 2003 version.
Sub x()
Dim olApp As Outlook.Application
Dim olNamespace As Outlook.Namespace
Dim olItem As MailItem

Set olApp = CreateObject("Outlook.application")
Set olNamespace = olApp.GetNamespace("Mapi")

For Each olItem In olNamespace.GetDefaultFolder(olFolderInbox).Items
Debug.Print olItem.Subject, olItem.SenderEmailAddress
Next

End Sub
Try using CDO
http://www.cdolive.com/cdo5.htm#GetSenderInformationthanks. The CDO approach worked fine.