Click to See Complete Forum and Search --> : html format e-mail using CDONTS?
Superfly1611
09-23-2003, 03:48 AM
Can i send an e-mail in html format using cdonts cause at the moment when i send an e-mail it is in plain text.
Well i presume it is... if i send a cdonts email using this body string....
<table>
<tr>
<td>Title</td><td>Price</td>
</tr>
<tr>
<td>Title</td><td>Price</td>
</tr>
<tr>
<td>Title</td><td>Price</td>
</tr>
</table>
it just outputs the string but doesn't render teh html.
The only reason i'm trying to send html is becuase i'm trying to structure the mail format.
And everytime i write a line break ("string" & vbNewLine) in my e-mail body Outlook removes the line breaks by default so my message looks like sh!te.
shanuragu
09-23-2003, 04:35 AM
Sure why not!!!,
All html tags should be enclosed with in double quotes , also take care no double quote is allowed with in this (replace all double quotes with in the tags with single quotes).
decalre a string variable which concatinates all html tags & finally palce the string variable in email body.
Dim emailmessage
emailmessage = emailmessage & "<html><head><title> Title Name</title></head>"
emailmessage = emailmessage & "<body>"
emailmessage = emailmessage & "<center>"
emailmessage = emailmessage & "<table align='center' border='0' width='500' cellspacing='0' cellpadding='0'>"
emailmessage = emailmessage & "<tr><td align='center'><font face='verdana' size='2'><b>Email message body</b></td></tr>"
emailmessage = emailmessage & "<tr><td align='center'><font face='verdana' size='2'><b>Email message body</b></td></tr>"
emailmessage = emailmessage & "</table>"
emailmessage = emailmessage & "</center>"
emailmessage = emailmessage & "</body>"
emailmessage = emailmessage & "</html>"
Set objMail = CreateObject("CDONTS.Newmail")
objMail.From = "test@test.com"
objMail.To = ToEmailAddress
objMail.Subject = " Email subject"
objMail.BodyFormat = 0
objMail.MailFormat = 0
objMail.Body = emailmessage
objMail.Send
Set objMail = Nothing
you can test it by writing the string variable into a a text file & executing the same before testing it online.
Good luck
shara
Ribeyed
09-23-2003, 04:39 AM
hi,
here are the answers to your questions as links:
http://www.aspfaq.com/show.asp?id=2474
This will show you the line you need to add for to make your emails from CDONTS HTML format. Something like this should work:
.HTMLbody = HTMLBody
For the line break you are just using the wrong code for linebreaks:
http://www.aspfaq.com/show.asp?id=2032
&vbCrLf
vbCrLf is for linebreaks not VBNewLine.
Hope this helps
Superfly1611
09-23-2003, 05:02 AM
cheers guys all sorted