Please proof this script for me

J

Jeremy Schubert

Can someone tell me if this looks correct?
----------------------------------------------------
On Error Resume Next

Const olDistributionListItem = 10

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olDistributionListItem)

Dim i As Integer
Dim objRecip As Outlook.Recipient
For i = objDL.MemberCount To 1 Step -1
Set objRecip = objDL.GetMember(i)
objDL.RemoveMember objRecip
Next
MsgBox objDL.MemberCount
Set objRecip = Nothing

Set objList = objFolder.Items("Math Teachers")

Set objGroup = GetObject("LDAP://[fill in your path here]CN=Finance
Users,OU=Finance,,DC=fabrikam,DC=com")

For Each strUser in objGroup.Member
Set objUser = GetObject("LDAP://" & strUser)
strUserName = objUser.displayName

Set objRecipient = objOutlook.Session.CreateRecipient(strUserName)
objRecipient.Resolve
objList.AddMember objRecipient
Next

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olDistributionListItem)

Dim i As Integer
Dim objRecip As Outlook.Recipient
For i = objDL.MemberCount To 1 Step -1
Set objRecip = objDL.GetMember(i)
objDL.RemoveMember objRecip
Next
MsgBox objDL.MemberCount
Set objRecip = Nothing

Set objList = objFolder.Items("Science Teachers")

Set objGroup = GetObject("LDAP://[fill in your path here]CN=Finance
Users,OU=Finance,,DC=fabrikam,DC=com")

For Each strUser in objGroup.Member
Set objUser = GetObject("LDAP://" & strUser)
strUserName = objUser.displayName

Set objRecipient = objOutlook.Session.CreateRecipient(strUserName)
objRecipient.Resolve
objList.AddMember objRecipient
Next

wscript.quit
 
J

Jeremy Schubert

Sorry guys! Posted in the wrong group!
Diane Poremsky said:
what happens when you run it?

--
Diane Poremsky [MVP - Outlook]





EMO - a weekly newsletter about Outlook and Exchange:
(e-mail address removed)

You can access this newsgroup by visiting
http://www.microsoft.com/office/community/en-us/default.mspx or point your
newsreader to msnews.microsoft.com.


Jeremy Schubert said:
Can someone tell me if this looks correct?
----------------------------------------------------
On Error Resume Next

Const olDistributionListItem = 10

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olDistributionListItem)

Dim i As Integer
Dim objRecip As Outlook.Recipient
For i = objDL.MemberCount To 1 Step -1
Set objRecip = objDL.GetMember(i)
objDL.RemoveMember objRecip
Next
MsgBox objDL.MemberCount
Set objRecip = Nothing

Set objList = objFolder.Items("Math Teachers")

Set objGroup = GetObject("LDAP://[fill in your path here]CN=Finance
Users,OU=Finance,,DC=fabrikam,DC=com")

For Each strUser in objGroup.Member
Set objUser = GetObject("LDAP://" & strUser)
strUserName = objUser.displayName

Set objRecipient = objOutlook.Session.CreateRecipient(strUserName)
objRecipient.Resolve
objList.AddMember objRecipient
Next

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olDistributionListItem)

Dim i As Integer
Dim objRecip As Outlook.Recipient
For i = objDL.MemberCount To 1 Step -1
Set objRecip = objDL.GetMember(i)
objDL.RemoveMember objRecip
Next
MsgBox objDL.MemberCount
Set objRecip = Nothing

Set objList = objFolder.Items("Science Teachers")

Set objGroup = GetObject("LDAP://[fill in your path here]CN=Finance
Users,OU=Finance,,DC=fabrikam,DC=com")

For Each strUser in objGroup.Member
Set objUser = GetObject("LDAP://" & strUser)
strUserName = objUser.displayName

Set objRecipient = objOutlook.Session.CreateRecipient(strUserName)
objRecipient.Resolve
objList.AddMember objRecipient
Next

wscript.quit
 

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