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: 55.031  | #24
◀ Previous sample Next sample ▶
Category-Manager Category-Manager
With Category-Manager you can group your Outlook categories, share them with other users, filter a folder by category, automatically categorize new emails, and more. You can use the Addin even for IMAP.

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
OLKeeper OLKeeper
OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or e-mails.
email  Send a message