Created
July 3, 2018 21:16
-
-
Save drewchapin/d085c5d5289b393cff385c953b110d0f to your computer and use it in GitHub Desktop.
VBScript to send an email without using Outlook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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