Multipart/alternative problem & questions HELP !!!
843830Jan 30 2002 — edited Oct 23 2002Hi,
I want to send an email with an HTML content and a text content (which can be very different from the HTML content).
I use the Mime : multipart/alternative
1/ Is it important to place the HTML part AFTER the text part?
Needed, when I put in first the HTML and in second the text, outlook shows the text part....
2/ I want to put a content text different from the HTML one, but the final mail contains the same content (in HTML format and in text format -without HTML tags-)
:(
3/ I don't understand why it's necessary to put 2 MimeBodyPart in this case !!! only the HTML BodyPart should be sufficient.
But, if I don't put the TEXT BodyPart.... the mail contains 2 parts, but the text part is empty (only the content-type and encoding , no body!)
I can't find the answers on the net...
Thanks in advance for your help
Agnes.
-------------------------------------
My code :
-------------------------------------
MimeMultipart multipart = new MimeMultipart("alternative") ;
String documentHTML="<HTML><A HREF=''>Hello from an HTML document</A></HTML>";
String documentText = "Bonjour !!!!";
MimeBodyPart bodyPartHtml = new MimeBodyPart();
bodyPartHtml.setContent(documentHTML,"text/html");
bodyPartHtml.setHeader("Content-Transfer-Encoding","8bit");
bodyPartHtml.setHeader("charset","iso-8859-1");
MimeBodyPart bodyPartText = new MimeBodyPart();
bodyPartText.setHeader("Content-Transfer-Encoding","8bit");
bodyPartText.setText(documentText,"iso-8859-1");
multipart.addBodyPart(bodyPartText);
mulltipart.addBodyPart(bodyPartHtml);
......
--------------------------------------------------------------
The mail received :
--------------------------------------------------------------
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_Part_0_2250.1012389581307"
------=_Part_0_2250.1012389581307
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
Hello from an HTML document
------=_Part_0_2250.1012389581307
Content-Type: text/html
Content-Transfer-Encoding: 8bit
charset: iso-8859-1
<HTML><A HREF='Hello from an HTML document</HTML>
------=_Part_0_2250.1012389581307--