Programmatically adding a contact to a distribution list?

  • Thread starter Thread starter Dieter Verlaeckt
  • Start date Start date
D

Dieter Verlaeckt

Hi all

I'm developing a COM add-in for Outlook using VC++ .NET 2003.

I have a couple of questions regarding contacts and distibution lists in
Outlook:

1) How can I programmatically add a certain contact to a distribution list?

I can add a 'Recipient' object to a distribution list, so how do i link that
'Recipient' object to a contact? I am basically looking to achieve the same
effect as when you would manually do a "Select Members..." to add contacts
to a distribution list in Outlook.

2) What is the difference internally between contact members (added using
"Select Members...") and normal members (added using "Add New...") of a
distribution list?

TIA

Dieter
 
1) When you do Select Members, you are in fact working with Recipient
objects in the address book -- each one corresponding to a contact's email
or fax address. You can use the Namespace.CreateRecipient method to create a
Recipient from whichever of the contact's addresses you want to use.

2) Add New can be used to create a recipient for one-off use in the DL
without creating an Outlook contact.
 
Thanks Sue,

That was what i wanted to know.

One more question: How can i simulate the "Add New" programmatically?

Dieter
 
You already have the answer below under #1 -- create a one-off recipient.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Still can't get it to completely work the way i want it to work, i must be
missing the obvious somewhere..

When using CreateRecipient (Redemption MAPIUtils version) i have the
following problems:

1. If i pass an unresolvable name to CreateRecipient i can't add an e-mail
address, because GetAddressEntry() returns NULL.

2. If i pass an e-mail address to CreateRecipient i can't add a name. I can
call GetAddressEntry() and do addressEntry->PutName(), but that doesn't
appear to do anything at all: when i do addressEntry->GetName() it returns
the old value again.

I have figured out that CreateRecipient does parse a string like "name
(e-mail address)" correctly, but then i have to go parse and construct
stuff.. there must be an easier solution right? :)

TIA

Dieter
 
Back
Top