B
barret bonden
Trying to add to an existing distribution list; (from MS Access to Outlook
2003) ; code below can add, but always creates new DL (see below); skipping
through Access records into general top level contacts was easy, DL work has
been very frustrating.
Code below works (it adds to a list) but it needs to refer to a known list.
How do I do this successfully ?
I've played with :
objDistList =
myFolder.Items.Add(Outlook.OlItemType.olDistributionListItem)
in other code but get "object variable not set" even though I can see it has
been !
Dim objOutlook As New Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objDistList As Outlook.DistListItem
Dim objMail As Outlook.MailItem
Dim objRecipients As Outlook.Recipients
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objDistList = objOutlook.CreateItem(olDistributionListItem)
Set objMail = objOutlook.CreateItem(olMailItem)
Set objRecipients = objMail.Recipients
objDistList.DLName = InputBox("Enter name of Distribution List")
'objDistList.DLName = "test"
'For i = 1 To Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row
'objRecipients.Add (Range("C" & i).Value)
'Next i
objRecipients.Add "(e-mail address removed)"
objRecipients.Add "(e-mail address removed)"
objDistList.AddMembers objRecipients
'objDistList.Display
objDistList.Save
objRecipients.ResolveAll
Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objDistList = Nothing
Set objMail = Nothing
Set objRecipients = Nothing
2003) ; code below can add, but always creates new DL (see below); skipping
through Access records into general top level contacts was easy, DL work has
been very frustrating.
Code below works (it adds to a list) but it needs to refer to a known list.
How do I do this successfully ?
I've played with :
objDistList =
myFolder.Items.Add(Outlook.OlItemType.olDistributionListItem)
in other code but get "object variable not set" even though I can see it has
been !
Dim objOutlook As New Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objDistList As Outlook.DistListItem
Dim objMail As Outlook.MailItem
Dim objRecipients As Outlook.Recipients
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objDistList = objOutlook.CreateItem(olDistributionListItem)
Set objMail = objOutlook.CreateItem(olMailItem)
Set objRecipients = objMail.Recipients
objDistList.DLName = InputBox("Enter name of Distribution List")
'objDistList.DLName = "test"
'For i = 1 To Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row
'objRecipients.Add (Range("C" & i).Value)
'Next i
objRecipients.Add "(e-mail address removed)"
objRecipients.Add "(e-mail address removed)"
objDistList.AddMembers objRecipients
'objDistList.Display
objDistList.Save
objRecipients.ResolveAll
Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objDistList = Nothing
Set objMail = Nothing
Set objRecipients = Nothing