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
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