Java Mail... Message.getContent().. can't get Content!
Anton Pechsherov
Greenhorn
Joined: Sep 09, 2008
Posts: 26
posted
0
Show INBOX for urkanah@pop.mail.ru From:=?KOI8-R?B?68nS2sHeIPPB0M/H?= <urkanah@gmail.com>
Subject: test Content: javax.mail.internet.MimeMultipart@787171
I can not get Content of my test message, how i can get it? Sorry of my english
I make different errors when writing posts...because i don't speak English...
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 32768
posted
0
The toString method of the MimeMultipart class doesn't return anything useful, as you can see. You'll need to iterate over all MIME parts using the getCount() and getBodyPart(int) methods. That'll provide you with MimeBodyPart objects that have various methods to give you access to their content.
Just remove the "Mime" part from Ulf's code. You should program against the interfaces and abstract classes anyway. Sure, getContent() returns a MimeMultipart now, but in the future that may change to some other Multipart implementation.
And don't forget to check the type of getContent() - it could very well be a String for plain text emails without attachments. So:
Rob Prime wrote:Just remove the "Mime" part from Ulf's code. You should program against the interfaces and abstract classes anyway. Sure, getContent() returns a MimeMultipart now, but in the future that may change to some other Multipart implementation.
And don't forget to check the type of getContent() - it could very well be a String for plain text emails without attachments. So:
Thanks... this is
subject: Java Mail... Message.getContent().. can't get Content!