• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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" );
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic