aspose file tools
The moose likes Servlets and the fly likes Want to include html in my email message... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply 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: 56157
    
  13

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


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About 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: 56157
    
  13

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Want to include html in my email message...
 
Similar Threads
servlet programming problem in Eclipse
How to send a Picture in Email
JAVA mail API : HTML mails are sent with html tags.
Validations: popup
Running JSP in Tomcat 5.5