如何在程序中获取outlook邮件服务器的通讯簿内容
aokon 2006-02-28 04:19:21 如题,不知道怎么解决,上午问了微软,给个VB的方案,没有整明白,请大家帮忙看看!!
Dim strQuery
Dim strUserDN
Dim strDomainDN
Dim oUser
strUserDN = "OU=UserAccounts,DC=fareast,DC=corp,DC=microsoft,DC=com"
' ================================
' Get the users who has a mailbox
' ================================
Set oConnection = CreateObject("ADODB.Connection")
Set oRootDSE = GetObject("LDAP://RootDSE")
Set oCommand = CreateObject("ADODB.Command")
varDomainNC = oRootDSE.Get("DefaultNamingContext")
oConnection.Provider = "ADsDSOObject"
oConnection.Open "ADs Provider"
strQuery = "<LDAP://" & strUserDN & ">;(&(objectClass=user)(mail=*));adspath,cn;subtree"
oCommand.ActiveConnection = oConnection
oCommand.CommandText = strQuery
Set RS = oCommand.Execute
while not RS.EOF
Set objUser = GetObject(RS.Fields("adspath"))
WScript.echo objuser.EmailAddress
RS.MoveNext
Wend