We help IT Professionals succeed at work.

How can i use jmail to write an html email that show html code?

frontechltd
frontechltd asked
on
490 Views
Last Modified: 2008-02-01
Hi All

I have a problem with sending email using jmail. At the moment i can send a html email using Jmail with no problem but i now need to send an email, with  js code for customers to put on there webpages, in it and jmail keep erroring with syntax or just not sending the email. There are two example below, one with present code and one with the code i want to send.

This is the bit of code i want to be shown in the email

<script type="text/javascript" src="http://*********************************/swfobject.js"></script>

Please help

****This works*****

<%
Set jmail = Server.CreateObject("JMail.Message")
jmail.AddRecipient "******"
jmail.From = "********"
jmail.Subject = "Js code for you"
jmail.HTMLBody = "<html><body>"
jmail.appendHTML "<img src=""*****.jpg"" >"
jmail.appendHTML "<br><br>"
jmail.appendHTML "<FONT FACE=""Arial"">"
jmail.appendHTML "Hi "
jmail.appendHTML ""& contactname & ""
jmail.appendHTML "<br /><br />Please follow the instructions below.<br />Please this bit of code between the head tags on every page .<br /><br />"
jmail.appendHTML "<FONT COLOR=""RED"">"
jmail.appendHTML "CODE WILL GO HERE"
jmail.appendHTML "<br /><br /></FONT>"
jmail.appendHTML "<FONT COLOR=""BLACK"">And this piece of code goes where you want the banner ad <br /><br /></FONT>"

jmail.appendHTML "</FONT></body></html>"


jmail.Send( "*******" )

%>

**** This does not *******

<%
Set jmail = Server.CreateObject("JMail.Message")
jmail.AddRecipient "******"
jmail.From = "********"
jmail.Subject = "Js code for you"
jmail.HTMLBody = "<html><body>"
jmail.appendHTML "<img src=""*****.jpg"" >"
jmail.appendHTML "<br><br>"
jmail.appendHTML "<FONT FACE=""Arial"">"
jmail.appendHTML "Hi "
jmail.appendHTML ""& contactname & ""
jmail.appendHTML "<br /><br />Please follow the instructions below.<br />Please this bit of code between the head tags on every page .<br /><br />"
jmail.appendHTML "<FONT COLOR=""RED"">"
jmail.appendHTML "<script type="text/javascript" src="http://*********************************/swfobject.js"></script>"
jmail.appendHTML "<br /><br /></FONT>"
jmail.appendHTML "<FONT COLOR=""BLACK"">And this piece of code goes where you want the banner ad <br /><br /></FONT>"
jmail.appendHTML "</FONT></body></html>"


jmail.Send( "*******" )

%>


Comment
Watch Question

Commented:
Double Quotes required

<%
Set jmail = Server.CreateObject("JMail.Message")
jmail.AddRecipient "******"
jmail.From = "********"
jmail.Subject = "Js code for you"
jmail.HTMLBody = "<html><body>"
jmail.appendHTML "<img src=""*****.jpg"" >"
jmail.appendHTML "<br><br>"
jmail.appendHTML "<FONT FACE=""Arial"">"
jmail.appendHTML "Hi "
jmail.appendHTML ""& contactname & ""
jmail.appendHTML "<br /><br />Please follow the instructions below.<br />Please this bit of code between the head tags on every page .<br /><br />"
jmail.appendHTML "<FONT COLOR=""RED"">"
jmail.appendHTML "<script type=""text/javascript"" src=""http://*********************************/swfobject.js""></script>"
jmail.appendHTML "<br /><br /></FONT>"
jmail.appendHTML "<FONT COLOR=""BLACK"">And this piece of code goes where you want the banner ad <br /><br /></FONT>"

jmail.appendHTML "</FONT></body></html>"


jmail.Send( "*******" )

%>

Author

Commented:
Thanks but i have tried the double quotes. All that happens is the email is sent but does not appear in the target email account.

Surely the double quotes will treat the code as part of the  html and try to run it with the rest. What i want is the line of code to appear as red text in the email.

Please correct me if im wrong

Commented:
try

<%
Set jmail = Server.CreateObject("JMail.Message")
jmail.AddRecipient "******"
jmail.From = "********"
jmail.Subject = "Js code for you"
jmail.HTMLBody = "<html><body>"
jmail.appendHTML "<img src=""*****.jpg"" >"
jmail.appendHTML "<br><br>"
jmail.appendHTML "<FONT FACE=""Arial"">"
jmail.appendHTML "Hi "
jmail.appendHTML ""& contactname & ""
jmail.appendHTML "<br /><br />Please follow the instructions below.<br />Please this bit of code between the head tags on every page .<br /><br />"
jmail.appendHTML "<FONT COLOR=""RED"">"
jmail.appendHTML Server.HTMLEncode("<script type=""text/javascript"" src=""http://*********************************/swfobject.js""></script>")
jmail.appendHTML "<br /><br /></FONT>"
jmail.appendHTML "<FONT COLOR=""BLACK"">And this piece of code goes where you want the banner ad <br /><br /></FONT>"

jmail.appendHTML "</FONT></body></html>"


jmail.Send( "*******" )

%>

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks the last one worked.

Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.