title: How to set MimeBodyPart ContentType to "text/html"?
body: <p>The program below shows an unexpected return value for HTML multipart MIME type. Why does this program print <code>text/plain</code> and not <code>text/html</code>?</p>
  <pre><code>public class Main {
    public static void main(String[] args) throws javax.mail.MessagingException, java.io.IOException {
      javax.mail.internet.MimeBodyPart mime_body_part = new javax.mail.internet.MimeBodyPart();
      mime_body_part.setContent(&quot;&lt;h1&gt;foo&lt;/h1&gt;&quot;, &quot;text/html&quot;);
      System.out.println(mime_body_part.getContentType());
    }
  }
  </code></pre>
  <p>I have tried numerous alternative ways including setting a <code>ByteArrayDataSource</code> wrapped in a <code>DataHandler</code>, but to no avail.  The same thing happens when I try this with a <code>MimeMessage</code> instead of a <code>MimeBodyPart</code>.</p>
  <p>To compile and run on Linux:</p>
  <pre><code>javac -classpath .:activation.jar:mail.jar Main.java
  java -classpath .:activation.jar:mail.jar Main
  </code></pre>