How to send an email using gmail and windows script….

Wouldn’t it be nice to run the script daily, or multiple times a day and have it automatically email with problems? To do that, you need to know how to send an email within script. If you research online, you’ll discover dozens (or more) ways people accomplish this. By far, the most popular is using the CDO approach.

<script language="VBScript">
Option Explicit
On Error Resume Next

Const fromEmail = ""
Const password = "xxxxxxxx"

Dim emailObj, emailConfig
Set emailObj = CreateObject("CDO.Message")
emailObj.From =
emailObj.To = ""
emailObj.Subject = "Test Email"
emailObj.TextBody = "It Works!!"

Set emailConfig = emailObj.Configuration
emailConfig.Fields("") = ""
emailConfig.Fields("") = 465
emailConfig.Fields("") = 2
emailConfig.Fields("") = 1
emailConfig.Fields("") = true
emailConfig.Fields("") = fromEmail
emailConfig.Fields("") = password
Set emailobj = nothing
Set emailConfig = nothing


The above script will let you send any text for the message body as an email to any address using your Gmail credentials. You could modify the parameters to use any other SMTP mail server you like.

This entry was posted in email, Gmail. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *