This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get Body text using javamail and retrieve to email

 
jordan ryan
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21126
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
still needing help on this i managed to get the to address this is now my code

 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what does this latest code do, and how does that differ from what you would like it to do?
 
jordan ryan
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic