Writing email addresses to variables using VBA

B

broken_penguin

I used the code below to check values in the To, Cc and Bcc fields. Email
addresses that are known to my address book are shown as a display name for
example (e-mail address removed) appears as Mayoor Jagjiwan. This
causes a problem because the 'display name' (Mayoor Jagjiwan) is written to
the variable. I need to write the email address to the variable in order to
check it against a list. So my question is: how do I read an email address
that is shown as a 'display name'?

Sub CustomMailMessageRule(Item As Outlook.MailItem)
Dim strCheck As String

MsgBox "Mail message arrived: " & Item.CC
strCheck = Item.CC

End Sub

Thanks in advance, Philip
 
S

Sue Mosher [MVP-Outlook]

Use the Item.Recipients collection. Each Recipient object has both a Name and an Address property, plus a Type property to tell you whether its a To, Cc, or Bcc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top