How to identify mail for specific user



Can anyone tell me if there is a way, using VBA, to
identify messages sent to a specific Outlook user from a
specific sender? Ultimately, I will include code that
will save, to a network folder, specifically named file
attachments that arrive with these messages.

An additional objective is to automatically run this code
in background not using an Outlook client...or at least
not require the above recipient to launch Outlook in order
to run this code. I had been considering either running a
scheduled task or possibly finding a way to run this code
from the mail server. Any thoughts?

Sue Mosher [MVP-Outlook]

The Recipients collection will tell you who the message was sent to, unless
the recipient got it as a Bcc.

As for the sender, you can use SenderName. If you need the address, too, in
Outlook 2003, you can use the MailItem.SenderEmailAddress, but note that
it's subject to security prompts in certain contexts.

In earlier versions, there is no Outlook property that returns the sender's
email address. You can either use CDO (or Redemption to avoid security
prompts -- to get the From address or
use Outlook to get the Reply To address. Sample code at

To get the SMTP address from an Exchange sender or recipient, use CDO or
Redemption and the PR_EMAIL (&H39FE001E) MAPI property to obtain the SMTP
address from the AddressEntry object. See and for examples.

It is not appropriate to run Outlook automation code on a server or as a
scheduled task, because of the likelihood that Outlook will display modal UI
that will halt the application.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question