Sdílet prostřednictvím


SenderEmailAddress Property

Returns a String that represents the e-mail address of the sender of the e-mail message, meeting item, or post. This property corresponds to the MAPI property PR_SENDER_EMAIL_ADDRESS. Read-only.

expression.SenderEmailAddress

*expression   * Required. An expression that returns one of the objects in the Applies To list.

Remarks

Microsoft Outlook blocks code that attempts to access the SenderEmailAddress property for security reasons. If you run a third-party add-in, custom solution, or other program that uses the SenderEmailAddress property in Microsoft Office Outlook   2003, you may receive the following warning:

A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may be a virus and you should choose "No".

Example

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 'someone@example.com'. To run this example without errors, make sure the Test folder exists in the default Inbox folder and replace 'someone@example.com' with a valid sender e-mail address in the Test folder.

Sub SetFlagIcon()
 Dim myOlApp As Outlook.Application
 Dim mpfInbox As Outlook.MAPIFolder
 Dim obj As Outlook.MailItem
 Dim i As Integer
 Set myOlApp = CreateObject("Outlook.Application")
 Set mpfInbox = myOlApp.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 = "someone@example.com" Then
    'Set the yellow flag icon
    obj.FlagIcon = olYellowFlagIcon
    obj.Save
   End If
  End If
 Next
End Sub

Applies to | MailItem Object | MeetingItem Object | PostItem Object