Addmembers and Distribution Lists

J

John Birtwistle

I want to create contacts in a folder "My Contacts" and also add them to a
Distribution List
also in the same folder.
The only way in which this can be done "reliably" is by using the email
address of the contact as recipient name.
If the code below is altered so that both contact and Distribution List are
in the default "Contacts" folder
there doesn't appear to be a problem - Why ?
Microsoft say that ADDMEMBERS doesn't work unless the email address is used
as recipient name for address resolution
at least for Outlook 2000. I am using 2002 ?
How do I get "friendly" names as display names in the Distribution List ?
The NAME and ADDRESS properties of Distribution list items appear to be read
only, so no prospect of writing
the "friendly" name back after item added.
Any suggestions gratefully received.
Incidentally I cannot get ADDMEMBER to work at all !
Microsoft supplied code snippets simply don't work. Even when adapted as for
ADDMEMBERS

Rem VB6 + OUTLOOK 2002
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myDistList As Outlook.DistListItem
Dim myMailItem As Outlook.MailItem
Dim myRecipients As Outlook.Recipients
Dim myContact As Outlook.ContactItem
Dim myFolder As Outlook.MAPIFolder
Set myNameSpace = myOlApp.GetNamespace("MAPI")

Set myFolder = myNameSpace.Folders("Personal Folders").Folders("My
Contacts")

Set myContact = myFolder.Items.Add(olContactItem)
myContact.FullName = "John B"
myContact.Email1Address = "(e-mail address removed)"
myContact.Save

Set myDistList = myFolder.Items.Add(olDistributionListItem)
Set myMailItem = myOlApp.CreateItem(olMailItem)
Set myRecipients = myMailItem.Recipients
myDistList.DLName = "My List"

Rem Only works if email address used as recipient TO name
myRecipients.Add "(e-mail address removed)"
Rem myRecipients.add "John B" doesn't work

myDistList.AddMembers myRecipients
myDistList.Save

Thanks,

John Birtwistle
 
B

BJD

John, I have exactly the same problem (using the same coding as you).
Can you post an entry here if you come up with a solution elsewhere.

BJD
 
J

John B

Hi BJD

It's a long time since I did this. I eventually got some code to work
though and I have a very fine collection of nested distribution lists
which have worked well for me.

There were issues with Outlook keeping old email addresses when they had
been deleted - I'm a bit hazy on it now. It seemed that some addresses
were getting put in the wrong lists. This seemed to be as a result of my
testing the code and leaving old addresses around in the My Contacts
folder. I manually deleted stuff and got a result. I think I removed all
address books and then got Outlook to reconstruct them - as I say it is
all a bit hazy to me now.

I can send you the code if you email me. It is pretty lengthy since its
part of a much larger program to read in names and email data from an
Excel file. You would have to dig around to find the relevant bits for
yourself.
I can also provide a text data file you to practice with.
If you want it I will change the addresses to non existent ones.

Regards
John B
 

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

Top