HTML construct shows as plain text in email body

Timax

Registered User.
Local time
Today, 14:12
Joined
May 14, 2015
Messages
33
I used HTML construct when sending email in email body but receive as a plain text. What am I missing? here is my code:

Function BuildHtmlBody(SQLStatement As String, ByVal Name As String)

Dim html, State, Qty

html = "<!DOCTYPE html><html><body>"
html = html & "<div style=""font-family:'Segoe UI', Calibri, Arial, Helvetica; font-size: 14px; max-width: 768px;"">"
html = html & "Dear {Name}, <br /><br />Please receive statement. <br />"
html = html & "Here is current status:<br /><br />"
html = html & "<table style='border-spacing: 0px; border-style: solid; border-color: #ccc; border-width: 0 0 1px 1px;'>"
Dim sql

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
sql = SQLStatement
Set rs = db.OpenRecordset(sql, dbOpenSnapshot)

rs.MoveFirst

Do While Not rs.EOF

State = Trim(rs!StateName)
Qty = Trim(rs!RealQty)

html = html & "<tr>"
html = html & "<td style='padding: 10px; border-style: solid; border-color: #ccc; border-width: 1px 1px 0 0;'>" & State & "</td>"
html = html & "<td style='padding: 10px; border-style: solid; border-color: #ccc; border-width: 1px 1px 0 0;'>" & Qty & "</td>"
html = html & "</tr>"

rs.MoveNext
Loop

html = html & "</table></div></body></html>"
BuildHtmlBody = html

End Function
 
What method are you using to send email from Access?
Check whether the code used to send the email is sending it as HTML or plain text.

If not it doesn't matter what HTML you use in your code, it will go as plain text as that is the default I believe.

If you need it, I have code to send HTML email from Access using CDO
 
As a note of caution for your, this line of code;
Code:
Dim html, State, Qty

Dims all the variables as Variant data types .
in Access you have to declare variables explicitly to set a data type e.g.

Code:
Dim HTML as String, State as String, Qty as Integer
 
Hi,

My company has a group policy enforced to convert all incoming emails as plain text for security. Perhaps your company does to? Try sending your email to a non-company address.

Just my 2 cents...
 
As a note of caution for your, this line of code;
Code:
Dim html, State, Qty

Dims all the variables as Variant data types .
in Access you have to declare variables explicitly to set a data type e.g.

Code:
Dim HTML as String, State as String, Qty as Integer

Thank you, Changed that.
 
What method are you using to send email from Access?
Check whether the code used to send the email is sending it as HTML or plain text.

If not it doesn't matter what HTML you use in your code, it will go as plain text as that is the default I believe.

If you need it, I have code to send HTML email from Access using CDO

Can you please send me CDO that sends HTML? I am using CDO to send but don't see any options for HTML or plain text.
 
Hi,

My company has a group policy enforced to convert all incoming emails as plain text for security. Perhaps your company does to? Try sending your email to a non-company address.

Just my 2 cents...

I just used outside email and still not getting HTML. These is got to be a way to send it as HTML
 
ok, I figured this out! I changed to .HTMLBody = strMessage and it worked! Thank you
 

Users who are viewing this thread

Back
Top Bottom