P
Paul Lambson
I am trying to send an email from excel to a distrobution list in
outlook. Any nifty code out there?
I found this on a group but can't get it to work.
Const olFolderContacts = 10
sDistName = "Friends" 'set the distribution list name here
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set colContacts = objNamespace.GetDefaultFolder
(olFolderContacts).Items
intCount = colContacts.Count
For i = 1 To intCount
If TypeName(colContacts.Item(i)) = "DistListItem" Then
Set objDistList = colContacts.Item(i)
sEmails = "";
If objDistList.DLName = sDistName Then
For j = 1 To objDistList.MemberCount
sEmails = sEmails & ";" & objDistList.GetMember
(j).Address
Next
'send the mail using the emails u got! ;-) enjoy
End If
End If
Next
Any help will be appreciated.
Thanks,
paul
outlook. Any nifty code out there?
I found this on a group but can't get it to work.
Const olFolderContacts = 10
sDistName = "Friends" 'set the distribution list name here
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set colContacts = objNamespace.GetDefaultFolder
(olFolderContacts).Items
intCount = colContacts.Count
For i = 1 To intCount
If TypeName(colContacts.Item(i)) = "DistListItem" Then
Set objDistList = colContacts.Item(i)
sEmails = "";
If objDistList.DLName = sDistName Then
For j = 1 To objDistList.MemberCount
sEmails = sEmails & ";" & objDistList.GetMember
(j).Address
Next
'send the mail using the emails u got! ;-) enjoy
End If
End If
Next
Any help will be appreciated.
Thanks,
paul