If wscript.arguments.count > 0 then
targetEmail = wscript.arguments.item(0)
else
wscript.echo "No email address specified"
wscript.quit
End if
SendMail targetEmail
wscript.quit
Sub SendMail (targetEmail)
' Put the message template here; assumes no in-template replacement for personalization to the recipient
' you can do either a full HTML-formatted message, or a simple plain-text message
strHTML = messagetemplate
Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort = 2
Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic = 1
Const cdoSendUserName = "http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword = "http://schemas.microsoft.com/cdo/configuration/sendpassword"
Dim objConfig ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields ' As ADODB.Fields
' Get a handle on the config object and it's fields
Set objConfig = CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
' Set config fields we care about
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mail.myisp.com"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "EMAIL ADDRESS/LOGIN"
.Item(cdoSendPassword) = "SMTP PASSWORD"
.Update
End With
Set objMessage = CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.To = "targetEmail"
' .CC = ' may be unnecessary
.From = "myemail@isp.com"
.Subject = "Stuff"
.HTMLBody = strHTML
.Send
End With
Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
End Sub
posted by devilsbrigade at 12:50 PM on March 28, 2006