Sending email with html tags

F

francan00

For sending email (with HTML tags) what is the best one to use?

I am using this now where it works except where I have <br> in the
message it doesnt add the newline to my output. Please advise if there
is something else I can use beside setContent?


// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/html");
Transport.send(msg);

Example of my what is in my message where everything works in the
Outlook email output except the <br> tag.


String message = "";
message += "Here is my link <a href='myaddresshere.com'>link</a><br>";
message += "<font color='green'>Next line of info here.</font><br>";
message += "<strong>Another line here</strong>";
 
J

j1mb0jay

For sending email (with HTML tags) what is the best one to use?

I am using this now where it works except where I have <br> in the
message it doesnt add the newline to my output. Please advise if there
is something else I can use beside setContent?


// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/html"); Transport.send(msg);

Example of my what is in my message where everything works in the
Outlook email output except the <br> tag.


String message = "";
message += "Here is my link <a href='myaddresshere.com'>link</a><br>";
message += "<font color='green'>Next line of info here.</font><br>";
message += "<strong>Another line here</strong>";

I think your existing <br> tag might have to become well formed xml
rather than not. To do this use the <br /> tag rather than the <br> tag.

Regards j1mb0jay
 
J

j1mb0jay

For sending email (with HTML tags) what is the best one to use?

I am using this now where it works except where I have <br> in the
message it doesnt add the newline to my output. Please advise if there
is something else I can use beside setContent?


// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/html"); Transport.send(msg);

Example of my what is in my message where everything works in the
Outlook email output except the <br> tag.


String message = "";
message += "Here is my link <a href='myaddresshere.com'>link</a><br>";
message += "<font color='green'>Next line of info here.</font><br>";
message += "<strong>Another line here</strong>";

Also trying using StringBuffer class rather than String concatenation as
it will much faster if you are sending larger messages.

Regards j1mb0jay
 
R

Roedy Green

Example of my what is in my message where everything works in the
Outlook email output except the <br> tag.

Try using a hex viewer or packet sniffer to examine messages going in
and out of your email program with blank links to see what it produces
and accepts. Then copy that syntax.

see http://mindprod.com/jgloss/hex.html
http://mindprod.com/jgloss/sniffer.html

I looked over some incoming emails in Eudora. I see lots of <br> and
<br />. Perahps it is just YOUR mailreader having trouble with them.
Try looking with something else.

See http://mindprod.com/jgloss/email.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top