SenderEmailAddress Property
Collapse the table of content
Expand the table of content

MailItem.SenderEmailAddress Property (Outlook)


Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Returns a String that represents the e-mail address of the sender of the Outlook item. Read-only.

expression .SenderEmailAddress

expression A variable that represents a MailItem object.

This property corresponds to the MAPI property PidTagSenderEmailAddress.

The following Microsoft Visual Basic for Applications (VBA) example loops all items in a folder named Test in the Inbox and sets the yellow flag on items sent by ''. To run this example without errors, make sure the Test folder exists in the default Inbox folder and replace '' with a valid sender e-mail address in the Test folder.

Sub SetFlagIcon() 
 Dim mpfInbox As Outlook.Folder 
 Dim obj As Outlook.MailItem 
 Dim i As Integer 
 Set mpfInbox = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("Test") 
 ' Loop all items in the Inbox\Test Folder 
 For i = 1 To mpfInbox.Items.Count 
 If mpfInbox.Items(i).Class = olMail Then 
 Set obj = mpfInbox.Items.Item(i) 
 If obj.SenderEmailAddress = "" Then 
 'Set the yellow flag icon 
 obj.FlagIcon = olYellowFlagIcon 
 End If 
 End If 
End Sub
© 2015 Microsoft