PDA

View Full Version : HTML email and CSS



next
11-11-2010, 03:19 PM
I trying to automatically send emails through excel, but CSS wasn't getting processed correctly, it was showing up as text in the message, like this:
*{margin: 0; padding: 0;}p {line-height: 16px;color: #666;margin: 10px 15px 20px 10px;}.phone {font-weight:bold;}table {font: 14px Verdana, Arial, Helvetica, sans-serif;}th {padding: 0 0.5em; text-align:center;border-top: 1px solid #FB7A31;border-bottom: 1px solid #FB7A31;background: #FFC;}td {border: 1px solid #CCC;padding: 0 0.5em;text-align:center;}.first {border-left: none;} .last {border-right: none;}#jobList {border-collapse:collapse;line-width:1px}#warning {font: 13px;color: blue;} .accent{text-decoration:underline;font-weight:bold;}

So when I researched this issue, I was told to use PDO instead. So I switched, the problem still remains... CSS is treated like basic text.

Does anyone know how to solve this issue? Here's an example of my code:
Sub test_x()
Dim email As String, crew As String, emailSubject As String, emailBody As String, CSS As String

crew = "VA-143"
email = "blah@blahblahblah.com"

CSS = "*{margin: 0; padding: 0;}" & _
"p {line-height: 16px;color: #666;margin: 10px 15px 20px 10px;}" & _
".phone {font-weight:bold;}" & _
"table {font: 14px Verdana, Arial, Helvetica, sans-serif;}" & _
"th {padding: 0 0.5em; text-align:center;border-top: 1px solid #FB7A31;border-bottom: 1px solid #FB7A31;background: #FFC;}" & _
"td {border: 1px solid #CCC;padding: 0 0.5em;text-align:center;}" & _
".first {border-left: none;} .last {border-right: none;}" & _
"#jobList {border-collapse:collapse;line-width:1px}" & _
"#warning {font: 13px;color: blue;} .accent{text-decoration:underline;font-weight:bold;}"


emailSubject = "(" & crew & ") Missing Signed Paperwork"
emailBody = "<html><head><style=text/css>" & CSS & _
"</style></head>" & _
"<body id=message><p>" & Greeting() & _
"</p><p> Our records indicate that we have not received signed paperwork for the " & _
"following jobs as of yet:</p>" & _
"<table id=jobList>" & _
"<th class=tHead>Account</th>" & _
"<th class=tHead>Name</th>" & _
"<th class=tHead>Store Number</th>" & _
"<th class=tHead>Address</th>" & _
"<th class=tHead>City</th>" & _
"<th class=tHead>State</th>" & _
"<th class=tHead>Service Date</th>" & _
"<th class=tHead>Work Order#</th></table>" & _
"<p>If you have already faxed the paperwork for any of the jobs referenced above, unless your fax was sent " & _
"two business days ago or less, please re-submit them, because currently we do not show these as received. " & _
"Please remember to submit your Invoices to us as well. " & _
"Our paperwork-dedicated fax number is: <span class=phone>(000)000 0000</span>.</p>" & _
"<p id=warning>* This message is automatically generated. Please <span class=accent>do not</span> reply to this email, " & _
"as it <span class=accent>will not</span> be answered. If you need to contact us, please don't hesitate to do so, we " & _
"can be reached at <span class=phone>(000)000 0000</span>.</p>" & _
"<p>Thank you.</p></body></html>"


CDOMail_SendMessage SendTo:=email, SendCC:="", SendBCC:="", _
From:="Accounting", ReplyTo:="blahblah@blah.com", _
Subject:=emailSubject, BodyHTML:=emailBody, BodyPlain:=""
End Sub

P.S. Here's the interesting thing though, when I used outlook to create and send emails, if instead of sending my email I choose to just construct and display it, CSS is processed as it should.