Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Option Explicit
Sub test()
Const cdoSendUsingPort = 2
Dim conf
Dim msg
Dim html_path
Dim html
Set conf = CreateObject("CDO.Configuration")
With conf.Fields
.Item("") = cdoSendUsingPort
.Item("") = "SMTP SERVER"
.Item("") = 587
.Item("") = False
.Item("") = 10
.Item("") = 1
.Item("") = "EMAIL"
.Item("") = "PASSWORD"
End With
html_path = "body.html"
html = ReadAllTextFile(html_path)
Set msg = CreateObject("CDO.Message")
With msg
Set .Configuration = conf
.To = "EMAL"
.From = "EMAL"
.Subject = "SUBJECT"
.HTMLBody = html
End With
Set msg = Nothing
Set conf = Nothing
MsgBox "Mail Sent!"
End Sub
Function ReadAllTextFile(path)
Const ForReading = 1
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(path, ForReading)
ReadAllTextFile = f.ReadAll
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment