aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes want to generate html formatted email that supports outlook? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "want to generate html formatted email that supports outlook?" Watch "want to generate html formatted email that supports outlook?" New topic
Author

want to generate html formatted email that supports outlook?

rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
Hi Friends,
I want to generate html formatted email using java that will be supported in outlook, actually i have tried org.apache.commons.mail.HtmlEmail still it fails for outlook.

Help me

Thanks
Rajesh
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42648
    
  65
What, exactly, do you mean by "fail"? What did you try, and how did or didn't it work? TellTheDetails


Ping & DNS - my free Android networking tools app
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
Sorry.

Im getting html formatted email in gmail, hotmail etc.but for outlook the mail is still text/plain.
The source code is
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
Hope my previous post has details, so that you provide sume suggestion.

Thanks
Rajesh
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42648
    
  65
That email doesn't seem to have any HTML ...

Make sure that Outlook isn't set to ignore HTML content, or that it's not stripped out by the target mail server.
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
String message ="test mail http://www.gmail.com";

the url will be treated as hyperlink when its a html email.so it works well as htnl formatted in googlemail,hot mail etc.but for out look its just a plain text
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

Make it explicit:
Apparently gmail is smarter than Outlook.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
Thanks for the suggestion
i tried the code you suggested still its a plain text email
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42648
    
  65
rajeshkannan sella wrote: String message ="test mail http://www.gmail.com";

That doesn't make it an HTML mail. Gmail simply renders any HTTP URLs as clickable links, that's all.

I'm not familiar with that Apache library, but this extensive tutorial with many code examples shows how to create HTML mails using JavaMail.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18911
    
    8

When I use my personal web-based e-mail account to send a message like that to my work e-mail account, Outlook doesn't recognize that piece of text as a URL and doesn't render it as a link.

So like everyone already said, that's what Outlook does with text e-mails. Send an HTML e-mail if that's what you want.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42648
    
  65
One more thing to try: make sure the HTML is well-formed - header, body, HTML tags etc.
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
For html formatted email we have a class called org.apache.commons.mail.HtmlEmail. im using that even though im not getting a html formatted email in outlook.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42648
    
  65
Just because there's a classes called "HtmlEmail" doesn't mean that it'll work with incorrect HTML.
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25


This code makes message body html formatted as per API reference
Lewin Chan
Ranch Hand

Joined: Oct 10, 2001
Posts: 214
rajeshkannan sella wrote:

This code makes message body html formatted as per API reference


I would try following the example from http://commons.apache.org/email/apidocs/org/apache/commons/mail/HtmlEmail.html; which constructs an actual HTML message, tags and all before submitting to HtmlEmail.

It seems somewhat optimistic to assume to assume that HtmlEmail can actually mark up what you have submitted as HTML (sure it might be add a couple of tags around of your text; but I would be pretty surprised if there was a full on text parser in it that understood when to make <a> tags and the like).

Try downloading the source to commons email and look at the source to HtmlEmail.

L
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
Thanks for the help.now i can able to generate html formatted email with the use Patterns
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: want to generate html formatted email that supports outlook?