• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help required - ContentType "alternate"  RSS feed

 
Amit Shanker
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I'm trying to use content type "alternate", which sends HTMT & plain text in an email. Depending on the client, whether it supports HTML, it displays text or HTML part. Now my problem is that on HTML based email client the code works fine. On non-HTML, it strips of certain tags. But I want to display my own custom message for plain text, which doesn't seem to work :-(

I've pasted the code snippet. On non-HTML email clients, I want my customised message "You need a HTML email client to read this mail." to be displayed. Now it just shows a stripped down version of the original HTML.

Any help would be really appreciated.

MimeMultipart mp = new MimeMultipart("alternative");

/** create the bodypart for the content */
MimeBodyPart htmlBody= new MimeBodyPart();
MimeBodyPart plainTextBody= new MimeBodyPart();

plainTextBody.setContent("You need a HTML email client to read this mail.","text/plain");
plainTextBody.setHeader("MIME-Version" , "1.0" );

htmlBody.setContent(htmlText,"text/html");
htmlBody.setHeader("MIME-Version" , "1.0" );
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!