AutoDiscoverXml 属性 (Outlook)NameSpace.AutoDiscoverXml property (Outlook)

返回一个字符串, 表示从用于承载主 exchange 帐户的 Microsoft Exchange server 的自动发现服务检索的 XML 中的信息。Returns a String that represents information in XML retrieved from the auto-discovery service for the Microsoft Exchange server that hosts the primary Exchange account. 此为只读属性。Read-only.

语法Syntax

expressionexpression. AutoDiscoverXml

_表达式_一个代表 "NameSpace" 对象的变量。expression A variable that represents a 'NameSpace' object.

说明Remarks

此属性类似于**Account** 对象的**AutoDiscoverXml** 属性。This property is similar to the AutoDiscoverXml property of the Account object. 如果在当前配置文件中定义的多个 Exchange 帐户,使用 AutoDiscoverXml 属性的特定帐户。If there are multiple Exchange accounts defined in the current profile, use the AutoDiscoverXml property for the specific account.

XML 的返回字符串包括有关各种 Web 服务(例如,可用性服务和统一邮件服务)和可用服务器的信息。The returned string of XML contains information about various Web services (for example, availability service and unified messaging service) and available servers.

如果活动配置文件不包含连接到 Microsoft Exchange Server 2007 或更高版本服务器的帐户,则会返回一个错误。An error is returned if the active profile does not contain an account that is connected to a server that is Microsoft Exchange Server 2007 or later.

示例Example

NameSpace.AutoDiscoverXml 是从 Exchange 服务器自动发现服务返回的 XML 字符串。NameSpace.AutoDiscoverXml is an XML string that is returned from the auto-discovery service of the Exchange server. 下面的代码示例使用 AutoDiscoverConnectionMode 属性来显示正常的 Outlook 会话期间可用该 XML 字符串时。The following code sample uses the AutoDiscoverConnectionMode property to show when this XML string is available during a normal Outlook session.

Dim WithEvents Session As NameSpace 
 
Dim LastAutoDiscoverXml As String 
 
Dim LastAutoDiscoverConnectionMode As OlAutoDiscoverConnectionMode 
 
 
 
Private Sub Application_Startup() 
 
 Set Session = Application.Session 
 
 If (Session.AutoDiscoverConnectionMode <> olAutoDiscoverConnectionUnknown) Then 
 
 LastAutoDiscoverXml = Session.AutoDiscoverXml 
 
 LastAutoDiscoverConnectionMode = Session.AutoDiscoverConnectionMode 
 
 DoAutoDiscoverBasedWork 
 
 End If 
 
End Sub 
 
 
 
Private Sub Session_AutoDiscoverComplete() 
 
 LastAutoDiscoverXml = Session.AutoDiscoverXml 
 
 LastAutoDiscoverConnectionMode = Session.AutoDiscoverConnectionMode 
 
 If LastAutoDiscoverConnectionMode <> olAutoDiscoverConnectionUnknown Then 
 
 DoAutoDiscoverBasedWork 
 
 End If 
 
End Sub 
 
 
 
Private Sub DoAutoDiscoverBasedWork() 
 
 ' Do activity requires auto discover information 
 
 Dim displayName As String 
 
 Dim posStartTag, posEndTag As Integer 
 
 posStartTag = InStr(1, LastAutoDiscoverXml, "<DisplayName>") 
 
 posEndTag = InStr(1, LastAutoDiscoverXml, "</DisplayName>") 
 
 
 
 If (posStartTag > 1 And posEndTag > 1) Then 
 
 displayName = Mid(LastAutoDiscoverXml, posStartTag + 13, posEndTag - posStartTag - 13) 
 
 Debug.Print "DisplayName = " & displayName 
 
 End If 
 
End Sub

另请参阅See also

命名空间对象NameSpace Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.