Email to a Distribution List in Access (1 Viewer)

Minty

AWF VIP
Local time
Today, 20:07
Joined
Jul 26, 2013
Messages
10,371
When you say Distribution Group, is this stored on centralised Exchange or is this a Contact Group local to your Outlook? If it's a local contact group try adding this into your code after the .Send

If Not .Recipients.ResolveAll Then
For Each Recipient In .Recipients
If Not Recipient.Resolved Then
MsgBox Recipient.Name & " could not be resolved"
End If
Next
End If
 

wsaccess

Registered User.
Local time
Today, 20:07
Joined
Dec 23, 2015
Messages
38
Hi Ginawhipp,

The version of MS Office that I am using is 2013.

Hi Minty,

Sorry about not being clear. Yes, when I say Distribution list, it is a contact group in my outlook.

I added the code as you suggested, and I get the following msgbox

"Test could not be resolved"

Thanks
 

wsaccess

Registered User.
Local time
Today, 20:07
Joined
Dec 23, 2015
Messages
38
Hi Grumm,

Thank you very much.
I wrote the following code and now it works!!!!!

Function GetDistLists()
'Get all the Distribution Lists in the Contacts Folder of Outlook and get the email IDs out of them into a string
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objFolder As Folder
Dim objItems As Items
Dim objList As Outlook.DistListItem
Dim objMember As Outlook.Recipient
Dim strAddrList As String
Dim i As Integer
Dim j As Integer
Set objOutlook = Outlook.Application
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNameSpace.GetDefaultFolder(olFolderContacts)
Set objItems = objFolder.Items
For i = 1 To objItems.Count
If TypeName(objItems.Item(i)) = "DistListItem" Then
Set objList = objItems.Item(i)
For j = 1 To objList.MemberCount
Set objMember = objList.GetMember(j)
strAddrList = strAddrList & objMember.Address & ";"
Next
End If
Next
Call SendEmail(strAddrList)

End Function

Function SendEmail(strAddrList)
'Send Email to the specific Distribution List
Dim objOLApp As Outlook.Application
Dim objMailItem As Outlook.MailItem
Dim strSubject As String
Set objOLApp = Outlook.Application
Set objMailItem = objOLApp.CreateItem(olMailItem)
With objMailItem
.To = strAddrList
.Subject = "This is a Test Mail"
.HTMLBody = "This is a test email to check the Distribution Lists"
.Send
End With
End Function
 

Users who are viewing this thread

Top Bottom