Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / December 2003

Tip: Looking for answers? Try searching our database.

Addmembers and Distribution Lists

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Birtwistle - 30 Oct 2003 01:03 GMT
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 = "jb@isp.co.uk"
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 "jb@isp.co.uk"
Rem myRecipients.add "John B" doesn't work

myDistList.AddMembers myRecipients
myDistList.Save

Thanks,

John Birtwistle
BJD - 29 Dec 2003 11:10 GMT
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

------------------------------------------------
BJD - 29 Dec 2003 11:11 GMT
Sorry - thanks!

BJD

------------------------------------------------
John B - 30 Dec 2003 21:13 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.