wood burning stoves 2.0*
The moose likes Servlets and the fly likes Want to include html in my email message... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Want to include html in my email message..." Watch "Want to include html in my email message..." New topic
Author

Want to include html in my email message...

Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
Hi,
I am using JAVA MAIL to send Email. I am able to send plain text messages properly but i want to send html contents in my message. How to do this?
I am able to send hyper links in my messages, but not html tags. what i mean by this is, let's say i send <H1>Hello</H1>, received email must be able to view this text in large font, rather than viewing like this(<H1>Hello</H1> . How to achive this. Could some body please help me on this.
Appreciate your help,
Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

Be sure to set the content type to "text/html".
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
Hi,
I want to allow attachments as well in my email message, so for this to happen i have set the contentType to multipart. Is there a way i can set to some contentType so that i can send both attachments as well as html contents. Also sometimes there could be only attachments, only html contents or both. So, how to achieve this?
Appreciate any further help on this.
Thanks for your response.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

Each part of a multipart message has a content type. Be sure to set each as appropriate to the content in that part.
Here's a link to a resource I found useful when I was toying with this very subject.
hth,
bear
[ June 19, 2002: Message edited by: Bear Bibeault ]
Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
Thanks for the response. Some how, i am not able to set the contentType to both multipart as well as text/html.
Is there a way to set the MimeMessage's contentType to both multipart as well as text/html?
If i set the mimeMessage's contentType to multipart, then i am able to send attachments in my email successfully, if i set the mimeMessage's contentType to text/html, then i am able to send html tags in my email message successfully. But i am not able to send both attachments as well as html tags in my email successfully. It defaults to whatever the last contentType was set to.
I would greatly appreciate any help on this.
Thanks in advance.
Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
I figured this out why it wasn't working. I was setting the contentType first to text/html and then again setting the mimeMessage's text, so the text was overriding text/html content type. Just wanted to share.
Thanks for your response.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Want to include html in my email message...
 
Similar Threads
JAVA mail API : HTML mails are sent with html tags.
servlet programming problem in Eclipse
Running JSP in Tomcat 5.5
How to send a Picture in Email
Validations: popup