This demonstrates how you could determine the text associated with the sender and the recipients.
You could try to determine SMTP addresses, those with the @ sign, but that is a bit more complicated.![]()
Option Explicit Sub CheckRecipients() Dim currItem As Object Dim currMail As MailItem Dim recip As recipient Set currItem = GetCurrentItem If TypeOf currItem Is MailItem Then Set currMail = currItem Debug.Print "Sender : " & currMail.Sender Debug.Print "SenderName : " & currMail.senderName Debug.Print "SenderEmailAddress: " & currMail.SenderEmailAddress Debug.Print For Each recip In currMail.Recipients If recip.Type = olTo Then Debug.Print recip & " is in the To line." If recip = "the text in the Debug.Print line" then ' code for recipients in the to line End if ElseIf recip.Type = olCC Then Debug.Print recip & " is in the cc line." Else Debug.Print recip & " is in the bcc line." ' Item in sent items folder End If Next recip End If Set currItem = Nothing Set currMail = Nothing End Sub Private Function GetCurrentItem() As Object Select Case TypeName(Application.ActiveWindow) Case "Explorer" Set GetCurrentItem = Application.ActiveExplorer.Selection.item(1) Case "Inspector" Set GetCurrentItem = Application.ActiveInspector.currentItem End Select End Function
Bookmarks