ForceConnection Method

ForceConnection Method

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The ForceConnection method attempts to recompute a route to deliver all messages in the link immediately, rather than waiting for the next scheduled connection.

Applies To

The ForceConnection method is a member of the Exchange_SMTPLink Class.

Instance Path

The ForceConnection method appears on instances of the \\COMPUTERNAME\ROOT\MicrosoftExchangeV2:Exchange_SMTPLink class.

MOF Syntax

[Implemented] void ForceConnection();

Qualifiers

Implemented

Parameters

This method has no mapped parameter values.

VBScript Example

'===============================================================
' Purpose:   Execute a ForceConnection on each Exchange_SMTPLink
' Change:    cComputerName [string] the computer to access
' Output:    Displays when the ForceConnection action occurs
'===============================================================

On Error Resume Next
Dim cComputerName
Const cWMINameSpace = "root/MicrosoftExchangeV2"
Const cWMIInstance = "Exchange_SMTPLink"
cComputerName = "MyComputerNETBIOSName"

Dim strWinMgmts		' Connection string for WMI
Dim objWMIExchange	' Exchange Namespace WMI object
Dim listExchange_SMTPLinks	' ExchangeLogons collection
Dim objExchange_SMTPLink		' A single ExchangeLogon WMI object

' Create the object string, indicating WMI (winmgmts), using the
' current user credentials (impersonationLevel=impersonate),
' on the computer specified in the constant cComputerName, and
' using the CIM namespace for the Exchange provider.
strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//"& _
cComputerName&"/"&cWMINameSpace
Set objWMIExchange =  GetObject(strWinMgmts)
' Verify we were able to correctly set the object.
If Err.Number <> 0 Then
  WScript.Echo "ERROR: Unable to connect to the WMI namespace."
Else
  '
  ' The Resources that currently exist appear as a list of
  ' Exchange_SMTPLink instances in the Exchange namespace.
  Set listExchange_SMTPLinks = objWMIExchange.InstancesOf(cWMIInstance)
  '
  ' Were any Exchange_SMTPLink Instances returned?
  If (listExchange_SMTPLinks.count > 0) Then
    ' If yes, do the following:
    ' Iterate through the list of Exchange_SMTPLink objects.
    For Each objExchange_SMTPLink in listExchange_SMTPLinks
   Wscript.Echo""
	Wscript.Echo "Forcing Connection on: " & objExchange_SMTPLink.LinkName
		objExchange_SMTPLink.ForceConnection
		If Err.Number <> 0 Then
			Wscript.Echo "WARNING:Error Forcing Connection: " & objExchange_SMTPLink.LinkName
			Err.Clear
		Else
			Wscript.Echo "ForceConnection Executed."
		End If
   Wscript.Echo""
    Next
  Else
    ' If no Exchange_SMTPLink instances were returned,
    ' display that.
    WScript.Echo "WARNING: No Exchange_SMTPLink instances were returned."
  End If
End If

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.