Send HTML Template With VBA

abbaddon223

Registered User.
Local time
Today, 05:54
Joined
Mar 13, 2010
Messages
162
Hello all,

I'm using the below to send emails from access. I have a HTML file saved on my desktop which is linked to a mail server. I need to be able to reference that HTML file (D:\Files\letter.html) and send it in the body of an email.

I've tried a basic file path on the .HTMLBody part of the below, but all it does is put the file path in the body :banghead:

Help appreciated!!!!!!!

Dim cdoConfig
Dim msgOne


Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = 587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.domain.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "name@domain.co.uk"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Password"

.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

.Update
End With

Set msgOne = CreateObject("CDO.Message")
Set msgOne.Configuration = cdoConfig
msgOne.To = "info@domain.co.uk"
msgOne.From = "info@domain.com"
msgOne.Subject = "SMTP Test"
msgOne.HTMLBody = [Need Help Here]
msgOne.send
MsgBox "Sent"

End Sub
 

Users who are viewing this thread

Back
Top Bottom