MailItem.To = 'John' instead of [email protected]

D

derobins

Hi,

I am creating a filter which uses the To and CC property to sort
mails.
Unfortunately many mails contain the name (eg. 'John Smith') instead
of the email address (eg. [email protected]) in the To or CC
property. How can I access the email address?

Thx!
 
D

Dmitry Streblechenko

Do not use To/CC/BCC properties to extract addresses.
Loop through all entries in the Recipients collection and for each item read
the value of the Recipient.Address property. The Recipient.Type property
will return the recipient kidn (olTo / olCC / olBCC)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
D

derobins

Thx for your answer :)
However, I have the same problem now for the SentOnBehalfOfName
property.
Again, it only shows me the name, but I need the email address.

I would appreciate any help,
Thank You!
 
D

Dmitry Streblechenko

OOM simply does not expose that.
You can retrieve the value of the PR_SENT_REPRESENTING_ENTRYID MAPI property
using PropertyAccessor in Outlook 2007 or Fields in CDO 1.21 and use it to
call Namespace.GetRecipientFromID.
<plug> Redemption (url below) exposes RDOMail.SentOnBehalfOf property
(returns RDOAddressEntry object) </plug>

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Top