A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

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



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 19th 06, 06:37 PM posted to microsoft.public.outlook.program_vba
K.N.Ganesh.
external usenet poster
 
Posts: 1
Default Adding a Member (existing in GAL) to a Public Distribution List in

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 = "
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

Ads
  #2  
Old May 23rd 06, 08:25 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Adding a Member (existing in GAL) to a Public Distribution List in

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
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"K.N.Ganesh." wrote in message ...
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.


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Superscript Text to a Distribution List Name Chatterbox Outlook - General Queries 1 May 17th 06 04:34 AM
Populate CC field from dropdown list & resolve against Outlook GAL Yvetta Outlook and VBA 1 April 9th 06 06:44 PM
How do i mail merge contacts from an existing list? Susana Outlook - General Queries 4 April 6th 06 10:32 AM
Outlook 2003 Distribution List doesn't show member names JMTP Outlook - Using Contacts 0 February 1st 06 04:16 PM
Adding Members to a Distribution List DeeW Outlook - Using Contacts 2 January 24th 06 08:20 PM


All times are GMT +1. The time now is 03:35 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.