Writing email addresses to variables using VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
Back
Top