Skip to content

Instantly share code, notes, and snippets.

@janzikan
Created May 4, 2014 06:19
Show Gist options
  • Save janzikan/5b07c43ca1e9f909d2ff to your computer and use it in GitHub Desktop.
Save janzikan/5b07c43ca1e9f909d2ff to your computer and use it in GitHub Desktop.
VBS: Send email
'****CONFIGURE THE FROM EMAIL ADDRESS AND PASSWORD
Const fromEmail = "[email protected]"
Const password = "password"
'****END OF CONFIGURATION
Dim emailObj, emailConfig
Set emailObj = CreateObject("CDO.Message")
emailObj.From = fromEmail
emailObj.To = "email_address"
emailObj.Subject = "Test"
emailObj.TextBody = "Text"
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment