'--- Test Email by Ben Millspaugh
'--- Version 1.2 (04/21/2003)

'--- Modify these setting to change the program defaults ---
	dfltMailServer = "mail.refron.com"
	dfltServerPort = "25"
	dfltFromEmail = "Jerry Kestenbaum <jerry@refron.com>"
	dfltToEmail = "Jerry Kestenbaum <jerry@refron.com>"
	dfltSubject = "Test message..."
	dfltBody = "Test message sent " & Now()
'--- End modification ---- Do not modify below this line ---

prgmTitle = "Test Email by Ben Millspaugh"
cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing"

Select Case MsgBox("Would you like to use the default settings?",3,prgmTitle)
	Case 6 'Yes
		mailServer = dfltMailServer
		serverPort = dfltServerPort
		fromEmail = dfltFromEmail
		toEmail = dfltToEmail
		subject = dfltSubject
		body = dfltBody
	Case 7 'No
		mailServer = InputBox("Please enter the SMTP mail server you would like to send a test message through.  It can be in the form of an IP address or a fully qualified domain name." & vbNewLine & vbNewLine & vbNewLine & "Mail Server:", prgmTitle, dfltMailServer)
		If mailServer = "" Then
			QuitScript("Test script can not continue without a mail server.")
		End If
		serverPort = InputBox("Please enter the TCP port you would like to use to connect to the SMTP mail server.  The default is port 25." & vbNewLine & vbNewLine & vbNewLine & "Server Port:", prgmTitle, dfltServerPort)
		If serverPort = "" Then
			QuitScript("Test script can not continue without a server port.")
		End If
		fromEmail = InputBox("Please enter the ""from"" e-mail address." & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & "From E-mail:", prgmTitle, dfltFromEmail)
		If fromEmail = "" Then
			QuitScript("Test script can not continue without a from e-mail address.")
		End If
		toEmail = InputBox("Please enter the ""to"" e-mail address." & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & "To E-mail:", prgmTitle, dfltToEmail)
		If toEmail = "" Then
			QuitScript("Test script can not continue without a to e-mail address.")
		End If
		subject = InputBox("Please enter the message subject." & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & "Subject:", prgmTitle, dfltSubject)
		If subject = "" Then
			QuitScript("Test script can not continue without a subject.")
		End If
		body = InputBox("Please enter the message body." & vbNewLine & vbNewLine & vbNewLine & vbNewLine & vbNewLine & "Body:", prgmTitle, dfltBody)
		If body = "" Then
			QuitScript("Test script can not continue without a body.")
		End If
	Case Else
		QuitScript("Test email canceled.")
End Select

Set msgConfig = CreateObject("CDO.Configuration")
msgConfig.Fields.Item(cdoSMTPServer) = mailServer
msgConfig.Fields.Item(cdoSMTPServerPort) = serverPort
msgConfig.Fields.Item(cdoSendUsingMethod) = 2
msgConfig.Fields.Update

Set cdoMsg = CreateObject("CDO.Message")
Set cdoMsg.Configuration = msgConfig

cdoMsg.From = fromEmail
cdoMsg.To = toEmail
cdoMsg.Subject = subject
cdoMsg.TextBody = body
cdoMsg.Send

Set cdoMsg = Nothing
Set msgConfig = Nothing

MsgBox "Message sent.", vbInformation, prgmTitle

Sub QuitScript(msgText)
	MsgBox msgText, vbExclamation, prgmTitle
	WScript.Quit
End Sub
