NameSpace.AutoDiscoverConnectionMode (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. Possible return values are olAutoDiscoverConnectionExternal - Connection is over the Internet, olAutoDiscoverConnectionInternal - Connection is over the Intranet, olAutoDiscoverConnectionInternalDomain - Connection is in the same domain over the Intranet, olAutoDiscoverConnectionUnknown - Other or unknown connection, or no connection.

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.


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, "") 
 
 posEndTag = InStr(1, LastAutoDiscoverXml, "") 
 
 
 
 If (posStartTag > 1 And posEndTag > 1) Then 
 
 displayName = Mid(LastAutoDiscoverXml, posStartTag + 13, posEndTag - posStartTag - 13) 
 
 Debug.Print "DisplayName = " & displayName 
 
 End If 
 
End Sub