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.088  | #24
◀ Previous sample Next sample ▶
ReplyAll ReplyAll
ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the e-mail.

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
SAM SAM
Determine the "identity" of your emails. Set with SAM the sender and the folder folder for sent items with the help of rules.
email  Send a message