Blat lets you send e-mails directly from batch files:
blat.exe - -f [email protected] -to [email protected] -s Subject -body "Text body" ^
-server smtp.example.com:25 -u username -pw password
But it seems that Blat doesn't support SSL, so to make it work with the Gmail you need an additional tool called Stunnel (see here and here).
Anyway, you should be able to send an e-mail via GMail from VBScript using the Collaboration Data Objects (CDO) COM API:
Const schema = "http://schemas.microsoft.com/cdo/configuration/"
Const cdoBasic = 1
Const cdoSendUsingPort = 2
Dim oMsg, oConf
' E-mail properties
Set oMsg = CreateObject("CDO.Message")
oMsg.From = "[email protected]" ' or "Sender Name <[email protected]>"
oMsg.To = "[email protected]" ' or "Recipient Name <[email protected]>"
oMsg.Subject = "Subject"
oMsg.TextBody = "Text body"
' GMail SMTP server configuration and authentication info
Set oConf = oMsg.Configuration
oConf.Fields(schema & "smtpserver") = "smtp.gmail.com"
oConf.Fields(schema & "smtpserverport") = 465
oConf.Fields(schema & "sendusing") = cdoSendUsingPort
oConf.Fields(schema & "smtpauthenticate") = cdoBasic
oConf.Fields(schema & "smtpusessl") = True
oConf.Fields(schema & "sendusername") = "[email protected]"
oConf.Fields(schema & "sendpassword") = "sender_password"
oConf.Fields.Update
oMsg.Send
Edit: Added the lacking sendusing
parameter so it should work fine now.
See here for more CDO examples.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…