gpm1982
11-18-2007, 10:02 PM
Hi everyone,
I'm not used to coding in VBScript, so I hope someone can help me out with this problem. Below is the code I write to get the members of the GAL (Global Address List) distribution list.
<html>
<head>
<script LANGUAGE="VBScript" type="text/vbscript">
CONST ServerName = "<servername>"
CONST MailBox = "<mailbox username>"
Sub Connect ()
Set cdoSession = CreateObject("MAPI.Session")
Set rdoSession = CreateObject("Redemption.RDOSession")
Set objOutlook = CreateObject("Outlook.Application")
Set nsOutlook = objOutlook.GetNamespace("MAPI")
cdoSession.Logon , , False, False, , True, ServerName & vbLf & MailBox
rdoSession.LogonExchangeMailbox MailBox, ServerName
End Sub
Sub Disconnect ()
cdoSession.Logoff
rdoSession.Logoff
Set cdoSession = nothing
Set rdoSession = nothing
End Sub
Function GetDistLists (strName)
Dim oAddrList
Dim oDistList
Set oAddrList = nsOutlook.AddressLists("Global Address List")
Set oDistList = oAddrList.AddressEntries(strName)
GetDistLists = oDistList
End Function
Sub viewMembers (strGroup)
Dim oDistList
Dim oListMember
Dim strMember
Set oDistList = GetDistLists(strGroup)
For Each oListMember In oDistList.Members
strMember = strMember & oListMember.Name & vbCrLf
Next
MsgBox strMember
End Sub
</script>
</head>
<body onLoad="Connect" onUnload="Disconnect">
<form name="formCDO">
View Members of this Distribution List:
<input type="text" name="txtGroup" size="20" />
<input type="button" value="View Members" onclick="viewMembers document.formCDO.txtGroup.value" />
</form>
</body>
</html>
When I run this code and click on the button, I get the following error:
Object Required: '[string: <group_name>]'
and I know the error is reflected from line:
Set oDistList = GetDistLists(strGroup)
but still, I don't know what causes the error.
I checked the entire website for this error message, but to no avail. Can anyone please help me with this problem? Thanks in advance.
I'm not used to coding in VBScript, so I hope someone can help me out with this problem. Below is the code I write to get the members of the GAL (Global Address List) distribution list.
<html>
<head>
<script LANGUAGE="VBScript" type="text/vbscript">
CONST ServerName = "<servername>"
CONST MailBox = "<mailbox username>"
Sub Connect ()
Set cdoSession = CreateObject("MAPI.Session")
Set rdoSession = CreateObject("Redemption.RDOSession")
Set objOutlook = CreateObject("Outlook.Application")
Set nsOutlook = objOutlook.GetNamespace("MAPI")
cdoSession.Logon , , False, False, , True, ServerName & vbLf & MailBox
rdoSession.LogonExchangeMailbox MailBox, ServerName
End Sub
Sub Disconnect ()
cdoSession.Logoff
rdoSession.Logoff
Set cdoSession = nothing
Set rdoSession = nothing
End Sub
Function GetDistLists (strName)
Dim oAddrList
Dim oDistList
Set oAddrList = nsOutlook.AddressLists("Global Address List")
Set oDistList = oAddrList.AddressEntries(strName)
GetDistLists = oDistList
End Function
Sub viewMembers (strGroup)
Dim oDistList
Dim oListMember
Dim strMember
Set oDistList = GetDistLists(strGroup)
For Each oListMember In oDistList.Members
strMember = strMember & oListMember.Name & vbCrLf
Next
MsgBox strMember
End Sub
</script>
</head>
<body onLoad="Connect" onUnload="Disconnect">
<form name="formCDO">
View Members of this Distribution List:
<input type="text" name="txtGroup" size="20" />
<input type="button" value="View Members" onclick="viewMembers document.formCDO.txtGroup.value" />
</form>
</body>
</html>
When I run this code and click on the button, I get the following error:
Object Required: '[string: <group_name>]'
and I know the error is reflected from line:
Set oDistList = GetDistLists(strGroup)
but still, I don't know what causes the error.
I checked the entire website for this error message, but to no avail. Can anyone please help me with this problem? Thanks in advance.