Today I wanted to send an email using SMTP from my gmail account. I searched the web and I found this and this and this which helped me a lot.
So this is the vbscript:
onerrorresumenextConstschema="http://schemas.microsoft.com/cdo/configuration/"ConstcdoBasic=1ConstcdoSendUsingPort=2DimoMsg,oConf' E-mail properties
SetoMsg=CreateObject("CDO.Message")oMsg.From="[email protected]"' or "Sender Name <[email protected]>"
oMsg.To="[email protected]"' or "Recipient Name <[email protected]>"
oMsg.Subject="Test from VBScript"oMsg.TextBody="If you can read this, the script worked!"' GMail SMTP server configuration and authentication info
SetoConf=oMsg.ConfigurationoConf.Fields(schema&"smtpserver")="smtp.gmail.com"'server address
oConf.Fields(schema&"smtpserverport")=465'port number
oConf.Fields(schema&"sendusing")=cdoSendUsingPortoConf.Fields(schema&"smtpauthenticate")=cdoBasic'authentication type
oConf.Fields(schema&"smtpusessl")=True'use SSL encryption
oConf.Fields(schema&"sendusername")="[email protected]"'sender username
oConf.Fields(schema&"sendpassword")="passwordi"'sender password
oConf.Fields.Update()' send message
oMsg.Send()' Return status message
IfErrThenresultMessage="ERROR "&Err.Number&": "&Err.DescriptionErr.Clear()ElseresultMessage="Message sent ok"EndIfWscript.echo(resultMessage)