don't know why, but your code didn't work for me Foxidrive. If it doesn't end up working for you rkp, here's one you could try. Only got it to work for gmail so far though (must have a gmail account to send from)
'Usage: cscript sendemail.vbs <[email protected]> "<subject_line>" "<email_body>" "<optional:email_attachment_path>"
'Ex. No attach: cscript sendemail.vbs [email protected] "test subject line" "test email body"
'Ex. W/ attach: cscript sendemail.vbs [email protected] "test subject line" "test email body" "c:\scripts\log.txt"
'***********
'****CONFIGURE THE FROM EMAIL ADDRESS AND PASSWORD
Const fromEmail = "[email protected]"
Const password = "xxxxxxxxxx"
'****END OF CONFIGURATION
'***********
Dim emailObj, emailConfig
Set emailObj = CreateObject("CDO.Message")
emailObj.From = fromEmail
emailObj.To = WScript.Arguments.Item(0)
emailObj.Subject = WScript.Arguments.Item(1)
emailObj.TextBody = WScript.Arguments.Item(2)
If WScript.Arguments.Count > 3 Then
emailObj.AddAttachment WScript.Arguments.Item(3)
End If
Set emailConfig = emailObj.Configuration
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = fromEmail
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = password
emailConfig.Fields.Update
emailObj.Send
Set emailobj = nothing
Set emailConfig = nothing
you'll want to save this as a mail.vbs
then using your batch file navigate to it and use the command:
mail <[email protected]> "<subject>" "<body>"
or
mail <[email protected]> "<subject>" "<body>" "<path:\\attachment>"
if those don't work, you could try the more wordy version
cscript sendemail.vbs <[email protected]> "<subject>" "<body>" "<path:\\attachment>"
if you put mail.vbs in your system32 folder (you may not want to) you can do this without navigating to it's location