• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help required - ContentType "alternate"

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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" );
reply
    Bookmark Topic Watch Topic
  • New Topic