> content
> I have tried many different avenues of setting the ContentType in my
> headers to "text/html". I would like to be able to send a text/html
> document as my mail message so that my end-users can view the mail as
html
> if the mail client they are using can display text/html. I have
> constructed a ContentType object and used the set/get Parameters as
shown
> below. I have also setHeaders implicity via: setHeader("Content-
> Type", "text/html") nothing seems to work. I set the MIME-Version to
> 1.0. I know that it can be done with perl. But obviously I want to do
it
> with Java!
>
>
> contentType = new ContentType();
> contentType.setParameter("MIME-Version", "1.0");
> contentType.setParameter("Content-Type", "text/html; charset=us-
ascii");
>
> try{
> theMessage.setHeader("MIME-Version", contentType.getParameter("MIME-
> Version"));
> theMessage.setHeader("Content-Type", contentType.getParameter
("Content-
> Type"));
> }
> catch(IllegalWriteException ie) {...}
> catch(MessagingException me) {...}
>
>
I have the answer to my own question. You can set headers all day long,
but that will do you nothing if you are using the setText() method of
MimeMessage. You have to use setContent() passing it both the content and
content-type. If you use setText() you will overwrite any headers that
you declare with "text/plain". In case anyone runs into this problem,
here is your answer.