email.vbs - vbscript script by ActiveXperts Software
email.vbs checks mail server by logging on and checking the status.
Use email.vbs directly from ActiveXperts Network Monitor; in the Manager's 'Monitor' menu, select 'New Check (Script)' and select email.vbs. Configure the required parameter, or press 'Load a working sample'.
In ActiveXperts Network Monitor, Administrators can use three different scripting languages: Powershell, VBScript and SSH.
email.vbs script code
' ///////////////////////////////////////////////////////////////////////////////
' // ActiveXperts Network Monitor - VBScript based checks
' // For more information about ActiveXperts Network Monitor and VBScript, visit
' // http://www.activexperts.com/support/network-monitor/online/vbscript/
' ///////////////////////////////////////////////////////////////////////////////
Option Explicit
' Declaration of global variables
Dim SYSDATA, SYSEXPLANATION ' SYSDATA is displayed in the 'Data' column in the Manager; SYSEXPLANATION in the 'LastResponse' column
' Constants - return values
Const retvalUnknown = 1 ' ActiveXperts Network Monitor functions should always return True (-1, Success), False (0, Error) or retvalUnknown (1, Uncertain)
' // To test a function outside Network Monitor (e.g. using CSCRIPT from the
' // command line), remove the comment character (') in the following lines:
' Dim bResult
' bResult = CheckSmtp( "smtp.activexperts-labs.com", 25, False, "", "" )
' WScript.Echo "Return value: [" & bResult & "]"
' WScript.Echo "SYSDATA: [" & SYSDATA & "]"
' WScript.Echo "SYSEXPLANATION: [" & SYSEXPLANATION & "]"
Function CheckSmtp( strSmtpHost, nPort, bIsSecure, strSmtpAccount, strSmtpPassword )
' Description:
' Logon to an SMTP mail server, either secure or not secure, optionally using an SMTP account and password
' SMTP servers always reply a '220' message when ready to establish a session
' ActiveXperts Mobile Messaging Component is automatically licensed when ActiveXperts Network Monitor is purchased.
' Parameters:
' 1) strSmtpHost - Host name or IP address of the mail server
' 2) nPort - Port number of the mail server. Default 25 for non-secure servers, 465 for secure servers
' 3) bIsSecure - Secure server or not
' 4) strSmtpAccount - Account name to logon to smtp server
' 5) strSmtpPassword - Password to logon to smtp server
' Usage:
' CheckSmtp( "<Hostname | IP>", <Port-Number>, <IsSecure>, <Account>, <Password> )
' Sample:
' CheckSmtp( "smtp.activexperts-labs.com", 25, False, "", "" )
Dim objSmtp
CheckSmtp = retvalUnknown ' Default return value, and will be shown as a yellow (uncertain) icon in the Manager
SYSDATA = "" ' SYSDATA displayed in the 'Data' column in the Manager
SYSEXPLANATION = "" ' SYSEXPLANATION displayed in the 'LastResponse' column in the Manager
Set objSmtp = CreateObject( "AxMmToolkit.Smtp" )
If( bIsSecure ) Then
objSmtp.SetSecure( nPort )
Else
objSmtp.HostPort = nPort
End If
objSmtp.Connect strSmtpHost, strSmtpAccount, strSmtpPassword
If( objSmtp.LastError <> 0 ) Then
CheckSmtp = False
SYSEXPLANATION = "Failed to connect to [" & strSmtpHost & "], error #" & objSmtp.LastError & ": " & objSmtp.GetErrorDescription( objSmtp.LastError )
Exit Function
End If
CheckSmtp = True
SYSEXPLANATION = "Response from [" & strSmtpHost & "]: [" & objSmtp.LastSmtpResponse & "]"
objSmtp.Disconnect
End Function
' //////////////////////////////////////////////////////////////////////////////
Function CheckPop3( strPop3Host, nPort, bIsSecure, strPop3Account, strPop3Password )
' Description:
' Logon to a POP3 mail server, either secure or not secure, using an POP3 account and password
' This function uses ActiveXperts Mobile Messaging Component.
' ActiveXperts Mobile Messaging Component is automatically licensed when ActiveXperts Network Monitor is purchased.
' Parameters:
' 1) strPop3Host - Host name or IP address of the mail server
' 2) nPort - Port number of the mail server. Default 110 for non-secure servers, 995 for secure servers
' 3) bIsSecure - Secure server or not
' 4) strPop3Account - Account name to logon to smtp server
' 5) strPop3Password - Password to logon to smtp server
' Usage:
' CheckPop3( "<Hostname | IP>", <Port-Number>, <IsSecure>, <Account>, <Password> )
' Sample:
' CheckPop3( "pop3.activexperts-labs.com", 110, False, "yourname", "yourpassword" )
Dim objPop3
CheckPop3 = retvalUnknown ' Default return value, and will be shown as a yellow (uncertain) icon in the Manager
SYSDATA = "" ' SYSDATA displayed in the 'Data' column in the Manager
SYSEXPLANATION = "" ' SYSEXPLANATION displayed in the 'LastResponse' column in the Manager
Set objPop3 = CreateObject( "AxMmToolkit.Pop3" )
If( bIsSecure ) Then
objPop3.SetSecure( nPort )
Else
objPop3.HostPort = nPort
End If
objPop3.Connect strPop3Host, strPop3Account, strPop3Password
If( objPop3.LastError <> 0 ) Then
CheckPop3 = False
SYSEXPLANATION = "Failed to connect to [" & strPop3Host & "], error #" & objPop3.LastError & ": " & objPop3.GetErrorDescription( objPop3.LastError )
Exit Function
End If
CheckPop3 = True
SYSEXPLANATION = "Response from [" & strPop3Host & "]: [" & objPop3.LastPop3Response & "]"
objPop3.Disconnect
End Function
