To get the sender's address from an Outlook mail
Microsoft Outlook provides a SenderName
property for the MailItem
object, but no obvious way to get the sender's e-mail address. Even
though Help suggests that the sender is part of the Recipients
collection, with Type
= olOriginator (0), it doesn't actually work that way.
We provide two functions here -- one to get the From address from
a message and a second to get the Reply To address. While these are
usually the same address, they may differ. In general, you need the
From address if you're performing tasks on incoming messages
depending on who sent them or if you want to add a sender to the
Contacts folder and be able to use the Look up Contact feature on
future messages from that person. You need the Reply To address if
you're planning to send messages to the sender.
Both routines are intended to handle just SMTP addresses. I have not made any effort
to handle non-SMTP addresses. This could be done by examining the
Type property of the Recipient or Sender (Sender is a CDO
AddressEntry object.) and adding code to include the type for
non-SMTP addresses, using the syntax [<type>:<address>].
The code below is for VBScript. You can also download
a VB/VBA module for Outlook 2000 that demonstrates both
functions with a ShowAddresses subroutine that writes the addresses
to the Immediate window.
Address | Get Reply Address |
Get From Address with Redemption | More Information