Skip to content

Instantly share code, notes, and snippets.

@drewchapin
Created July 3, 2018 21:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewchapin/d085c5d5289b393cff385c953b110d0f to your computer and use it in GitHub Desktop.
Save drewchapin/d085c5d5289b393cff385c953b110d0f to your computer and use it in GitHub Desktop.
VBScript to send an email without using Outlook
Sub SendEmail( fromAddress, toAddress, subject, body )
On Error Resume Next
Dim Email
Set Email = CreateObject("CDO.Message")
Email.From = fromAddress
Email.To = toAddress
Email.Subject = subject
Email.TextBody = body
Email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.google.com"
Email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
Email.Configuration.Fields.Update
Email.Send
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment