wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes get Body text using javamail and retrieve to email 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 "get Body text using javamail and retrieve to email" Watch "get Body text using javamail and retrieve to email" New topic
Author

get Body text using javamail and retrieve to email

jordan ryan
Greenhorn

Joined: Oct 31, 2012
Posts: 19
Im currently using .getContent() to retrieve the body, but its not working its giving me something like this "javax.mail.internet.MimeMultipart@1cfb549"

Is there anyway i can just get the body text of the email?

Also i need to get the TO Address (my address) im currently trying to use getRecipients(Message.RecipientType.TO) but it just comes back with something like "[L]javax.mail.internet.internetAddress;@4a5ab2"

Any help would be great
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You are getting the right objects there. But when you print them using System.out.println, you don't see anything meaningful because they don't implement the toString() method.

So if you write code which calls methods of those objects to extract the data you want, you should find they are the right objects. I haven't checked the API documentation to see what those methods are, but if you have got so far as to produce those objects, I expect you won't have any problem finding out. Or if you do, go ahead and post that question here along with your code so far.
jordan ryan
Greenhorn

Joined: Oct 31, 2012
Posts: 19
i think i know what you mean but i cant really work out how to implement it. lines 45 and 53 are were the problem is i think.
jordan ryan
Greenhorn

Joined: Oct 31, 2012
Posts: 19
i found out this is the code i most likely will need to use but can some one dumb this down for me as im struggling to understand how to put it in my current code.


jordan ryan
Greenhorn

Joined: Oct 31, 2012
Posts: 19
still needing help on this i managed to get the to address this is now my code

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41089
    
  44
So what does this latest code do, and how does that differ from what you would like it to do?


Ping & DNS - my free Android networking tools app
jordan ryan
Greenhorn

Joined: Oct 31, 2012
Posts: 19
the getContent returns the content as a object soo i need to work out how to pass the object to change it into corresponding strings i Currently worked a bit on it yesterday and i found a way to do it but it fell off on one of my E-mails.



this is the error i get when i run the program it shows me my first 3 emails fine then the 4th says javax.mail.internet.MimeMessage@5d173. then it stops running.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

The message is UTF-7 encoded, and Java has no support for UTF-7 by default. I solved that using https://sourceforge.net/projects/jutf7/ once. Just add it to your class path; it uses the ServiceLoader mechanism to install itself.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get Body text using javamail and retrieve to email
 
Similar Threads
sending to email using JSP
posts via email?
regarding auto mail system
Email Validation
Using SMTPAppender with MS Outlook