Using AddNewMember for a Distribution list

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'd like to write what should be a pretty basic macro in VBA for Outlook.
Here's how it should work:


When I receive an email containing a particular subject line, I would like
to be able to move that email message to a specified folder, respond to the
sender with a specified message and add that sender's address to an existing
distribution list.

It looks like I can do the first two things with a rule and that adding the
email address to the distribution list may require some VBA. So, what I need
are some hints on how to extract the sender's email address from these
incoming emails and add it to a distribution list.

I have done quite a bit of VBA in Excel and Access but this will be my first
try at VBA in Outlook so I would appreciate any help from those more seasoned
than I.

Regards,
 
In Outlook 2003, you can use the MailItem.SenderEmailAddress.

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.

For the DL, take a look at the Namespace.CreateRecipient and
DistListItem.AddMember methods.
 
Back
Top