Site Name Error with ADSI

  • Thread starter Thread starter Ken Parchinski
  • Start date Start date
K

Ken Parchinski

I am trying to create a custom recipient in our Exchange
5.5 SP4 Server Address Book using ADSI and the following
code. I retrieved the site name (OU) and organizational
unit (O) from similar routines I found on the MSDN
website. The problem, I am thinking, is that our site
name has a comma in it (Company Name, Inc.) and the
parameters are comma separated. I am receiving a -
2147016656 Automation Error - There is no such object on
the server. I sent an email to Stein Borge who authored a
WSH book and he suggested a \ prior to the , in the site
name; however, this did not work.

Function CreateCustomRecipient(ByVal sServerName As
String, ByVal sOU As String, ByVal sSN As String) As
Boolean

Dim strDisplayname As String
Dim strAlias As String
Dim objCont As IADsContainer
Dim objNewCR As IADs

On Error GoTo ERR_MESSAGE
'Debug.Print "LDAP://exchsvr/cn=Recipients,ou=Automated
Resources Group\,Inc.,o=ARGI"
Set objCont = GetObject
("LDAP://exchsvr/cn=Recipients,ou=Automated Resources
Group, Inc.,o=ARGI")
Set objNewCR = objCont.Create("Remote-Address", CStr
("cn=" & strAlias))
objNewCR.Put "cn", CStr(strDisplayname)
objNewCR.Put "uid", CStr(strAlias)
objNewCR.Put "Target-
Address", "SMTP:[email protected]"
objNewCR.SetInfo
CreateCustomerRecipient = True
Exit Function

ERR_MESSAGE:
'MsgBox CStr(Err.Number) & " - " & Err.Description
CreateCustomRecipient = False
End Function
 
Back
Top