Skip to content

@honda0510 /gist:2007377
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
CDOでHTMLメール送信
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("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP SERVER"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "EMAIL"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "PASSWORD"
.Update
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
.Send
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
Something went wrong with that request. Please try again.