NameSpace.AutoDiscoverConnectionMode Property

Outlook Developer Reference

Returns an OlAutoDiscoverConnectionMode constant that specifies the type of connection to the Exchange server for auto-discovery service. Read-only.

Version Information
 Version Added:  Outlook 2007

Syntax

expression.AutoDiscoverConnectionMode

expression   A variable that represents a NameSpace object.

Example

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

  1. When the Application.Startup event occurs, if AutoDiscoverConnectionMode is not equal to olAutoDiscoverConnectionUnknown
  2. When the NameSpace.AutoDiscoverComplete event occurs, if AutoDiscoverConnectionMode is not equal to olAutoDiscoverConnectionUnknown
Visual Basic for Applications
  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 &gt; 1 And posEndTag &gt; 1) Then
    displayName = Mid(LastAutoDiscoverXml, posStartTag + 13, posEndTag - posStartTag - 13)
    Debug.Print "DisplayName = " &amp; displayName
End If

End Sub

See Also