File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes Javamail: Retrieve text/plain part of an multipart/alternative message? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Javamail: Retrieve text/plain part of an multipart/alternative message?" Watch "Javamail: Retrieve text/plain part of an multipart/alternative message?" New topic
Author

Javamail: Retrieve text/plain part of an multipart/alternative message?

Ron Spaulding
Greenhorn

Joined: May 03, 2011
Posts: 3
Hi,

I sent an mail as "multipart/alternative" using Googlemail. If I check the properties of the mail in Outlook 2007 (right-click on message -> properties) it also shows up as multipart/alternative.
However if I retrieve the mail using Javamail (from an MS Exchange-Server) the contenttype of the message is "text/html" :-(

My question is therefore how to obtain the original multipart-message or the text/plain part?

Cheers,
Spaulding

PS: For security reasons I do not want to deal with html messages. Therefore my program should only accept mails in text/plain format...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

With your JavaMail download there is a directory of example programs. One is a program to extract all of the parts from a message. Run that program on your multipart/alternative message and see if there is a text/plain part hidden inside it.
Ron Spaulding
Greenhorn

Joined: May 03, 2011
Posts: 3
You are probably referring to "mgsshow.java"?

I already checked that and even there it's showing up as text/html only...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Ron Spaulding wrote:You are probably referring to "mgsshow.java"?


Yes.

I already checked that and even there it's showing up as text/html only...


Really? You would think that a "multipart" message would have more than one part. However I've never had to process an incoming multipart/alternative message via JavaMail myself, so I have no expertise to add at this time.
Ron Spaulding
Greenhorn

Joined: May 03, 2011
Posts: 3
I think the problem is the MS Exchange-Server.
Instead of sending the multipart/alternative messages it just sends the text/html one... Is there a way to tell the server that the client does not understand text/html messages?


However I've never had to process an incoming multipart/alternative message via JavaMail myself, so I have no expertise to add at this time.


Nevertheless your help is greatly appreciated.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Ron Spaulding wrote:I think the problem is the MS Exchange-Server.
Instead of sending the multipart/alternative messages it just sends the text/html one... Is there a way to tell the server that the client does not understand text/html messages?


I don't know... there's a lot of IMAP properties you could set, you can read about them in this API docs page.
 
Consider Paul's rocket mass heater.
 
subject: Javamail: Retrieve text/plain part of an multipart/alternative message?
 
Similar Threads
JAVA MAIL retriving text/ html and Text/plain
Java Mail receive Problem
Javamail - how to mix static and dynamic plain text content?
javamail API question: How to send content type in message body when using multiparts
JavaMail - Problem while sending file attachment