Adding a Member (existing in GAL) to a Public Distribution List in

K

K.N.Ganesh.

Hi,

Abbreviations used:
GAL - Global Address List (Stored / retrieved from Exchange Server).
PDL - Public Distribution List stored in Exchange server.

Aim: I am trying to add a member (user present in GAL) to a Public
Distribution List (PDL) stored in GAL.

Background Info:
1. I am the owner of the PDL.
2. I can do this in outlook cline UI as Tools -> Address Book -> Select the
PDL from GAL -> View Properties -> click Modify Members -> Click Add -> In
the resulting dialog select the user from GAL to be added.
3. I want to do this (step 2 mentioned above) programmatically using VBA in
Outlook or Excel.
4. I am using outlook 2003 SP2
5. I picked some sample codes in this forum to write the code given below.
6. I tried to search through and read this forum to solve it myslef. I
couldn't find a solution myself.
7. I am new to this forum.

Problem Faced:
Refer the program given below.
While running (or Stepping through) Line 23 I am getting the error:
---Error Dialog Start---
Run-time error '-2147221246 (80040102)
Automation error
Invalid window handle
---Error Dialog End---

Thanks for all your help and time. Let me know if you need any more info.
Sorry If I have validated any code of conduct of this forum.

Regards,
K.N.Ganesh.

Program Used:

Sub cleanAddNewDistListMemberV2()
strDistListName = "GAL_DLListName"
strDistListMemberToAddName = "LastName, FirstName"
strDistListMemberToAddMailId = "(e-mail address removed)"
Dim objOutlookApp 'As New Outlook.Application
Dim objOutlookNamespace '
Dim objDistListItem 'As DistListItem
Dim objMailItem 'As MailItem
Dim objRcpnt 'As Recipient

Set objOutlookApp = CreateObject("Outlook.Application")
Set objOutlookNamespace = objOutlookApp.GetNamespace("MAPI")
Set addrList = objOutlookNamespace.AddressLists("Global Address List")
Set addrListEntries = addrList.AddressEntries(strDistListName)
Set myaddrListMembers = addrListEntries.Members

'Resolve the user to be added.
Set objMailItem = objOutlookApp.CreateItem(olMailItem)
Set objRcpnt = objMailItem.Recipients.Add(strDistListMemberName & Chr(32) &
strDistListMemberMail)
If objRcpnt.Resolve Then
'Add the user to the addrListMembers
'Line 22
Set updateAddrEntry = myaddrListMembers.Add(objRcpnt)
'Commit the change
updateAddrEntry.Update
End If



Set objOutlookApp = Nothing
Set objOutlookNamespace = Nothing
Set objDistListItem = Nothing
Set objMailItem = Nothing
Set objRcpnt = Nothing

End Sub
 
S

Sue Mosher [MVP-Outlook]

You'll need to use ADSI, not Outlook objects or CDO. The right forum might be microsoft.public.exchange.development
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top