foosy
11-01-2015, 03:25 PM
I would like to create an exchange public group which I own. The list of contacts in it are going to be email addresses (not from the domain).
The goal is an exchange stored distribution list, which could be used by rules.
Below is the closest code I have found for listing members. How would you modify this so that you could add a member to the exchanche distribution list?
Any pointer to such code would be greatly appreciated.
Sub GetDGMembers()
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olAL As Outlook.AddressList
Dim olEntry As Outlook.AddressEntry
Dim olMember As Outlook.AddressEntry
Dim lMemberCount As Long
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set olAL = olNS.AddressLists("Global Address List")
Set objMail = olApp.CreateItem(olMailItem)
' enter the list name
Set olEntry = olAL.AddressEntries("Advertiser Inquiries")
' get count of dist list members
lMemberCount = olEntry.Members.Count
' loop through dist list and extract members
Dim i As Long
For i = 1 To lMemberCount
Set olMember = olEntry.Members.Item(i)
strName = olMember.Name
strAddress = olMember.GetExchangeUser.PrimarySmtpAddress
strPhone = olMember.GetExchangeUser.BusinessTelephoneNumber
objMail.Body = objMail.Body & strName & " -- " & strAddress & " -- " & strPhone & vbCrLf
Next i
objMail.Display
End Sub
The goal is an exchange stored distribution list, which could be used by rules.
Below is the closest code I have found for listing members. How would you modify this so that you could add a member to the exchanche distribution list?
Any pointer to such code would be greatly appreciated.
Sub GetDGMembers()
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olAL As Outlook.AddressList
Dim olEntry As Outlook.AddressEntry
Dim olMember As Outlook.AddressEntry
Dim lMemberCount As Long
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set olAL = olNS.AddressLists("Global Address List")
Set objMail = olApp.CreateItem(olMailItem)
' enter the list name
Set olEntry = olAL.AddressEntries("Advertiser Inquiries")
' get count of dist list members
lMemberCount = olEntry.Members.Count
' loop through dist list and extract members
Dim i As Long
For i = 1 To lMemberCount
Set olMember = olEntry.Members.Item(i)
strName = olMember.Name
strAddress = olMember.GetExchangeUser.PrimarySmtpAddress
strPhone = olMember.GetExchangeUser.BusinessTelephoneNumber
objMail.Body = objMail.Body & strName & " -- " & strAddress & " -- " & strPhone & vbCrLf
Next i
objMail.Display
End Sub