VBOffice

Display the Sender Address in Outlook 2000

This macro enables you to get the sender's address even in older versions of Outlook.

Last modified: 2006/05/05 | Accessed: 56.588  | #24
◀ Previous sample Next sample ▶
Reporter Reporter
VBOffice Reporter is an easy to use tool for data analysis and reporting in Outlook. A single click, for instance, allows you to see the number of hours planned for meetings the next month.

Before Outlook 2003 it wasn't possible to get the email address of the sender via the Outlook object model. The Sender property back then showed the display name instead.

See how to get the address by using the Redemption. The macro adds a user property named 'SenderAddress', which you can add to the fields displayed in the inbox.


tip  How to add macros to Outlook
Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
  Set Items = Application.GetNamespace("MAPI") _
    .GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
  If TypeOf Item Is Outlook.MailItem Then
    AddSenderEmailAddress Item
  End If
End Sub

Private Sub AddSenderEmailAddress(Mail As Outlook.MailItem)
  On Error Resume Next
  Dim rdItem As Object
  Dim Field As Outlook.UserProperty

  Set rdItem = CreateSafeItem(Mail)

  Set Field = Mail.UserProperties("SenderAddress")
  If Field Is Nothing Then
    Set Field = Mail.UserProperties.Add("SenderAddress", olText, True)
  End If

  Field.Value = rdItem.SenderEmailAddress
  Mail.Save

  ReleaseSafeItem rdItem
End Sub
ReplyAll ReplyAll
ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the e-mail.
email  Send a message