Skip to content

Latest commit

 

History

History
119 lines (56 loc) · 3.07 KB

Outlook.NameSpace.AutoDiscoverConnectionMode.md

File metadata and controls

119 lines (56 loc) · 3.07 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
NameSpace.AutoDiscoverConnectionMode property (Outlook)
vbaol11.chm3303
vbaol11.chm3303
Outlook.NameSpace.AutoDiscoverConnectionMode
a73a71ca-0f40-3c7e-bb89-9d6a45775c6f
06/08/2017
medium

NameSpace.AutoDiscoverConnectionMode property (Outlook)

Returns an OlAutoDiscoverConnectionMode constant that specifies the type of connection for auto-discovery of the Microsoft Exchange server that hosts the primary Exchange account. Read-only.

Syntax

expression. AutoDiscoverConnectionMode

expression A variable that represents a 'NameSpace' object.

Remarks

This property is similar to the AutoDiscoverConnectionMode property of the Account object. If there are multiple Exchange accounts defined in the current profile, use the AutoDiscoverConnectionMode property for the specific account.

Example

NameSpace.AutoDiscoverXml is an XML string that is returned from the auto-discovery service of the Exchange server. The following code sample uses the AutoDiscoverConnectionMode property to show when this XML string is available during a normal Outlook session.

  • When the Application.Startup event occurs, if AutoDiscoverConnectionMode is not equal to olAutoDiscoverConnectionUnknown.

  • When the NameSpace.AutoDiscoverComplete event occurs, if AutoDiscoverConnectionMode is not equal to olAutoDiscoverConnectionUnknown.

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

[!includeSupport and feedback]