How to identify mail for specific user

  • Thread starter Thread starter MikeC
  • Start date Start date
M

MikeC

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?
 
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 -- http://www.dimastr.com/redemption/) to get the From address or
use Outlook to get the Reply To address. Sample code at
http://www.outlookcode.com/d/code/getsenderaddy.htm

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
http://www.outlookcode.com/d/code/getsenderaddy.htm#redemption and
http://www.cdolive.com/cdo5.htm#EMailAddressOfSender 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.
 
Back
Top