• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Save email body content in a file on disk

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I'm new to this Forum and first of all i would really like to thank all of you for providing such a nice and sorted facility to post our doubts. I really appreciate this...

Now i'm working with emails and i have created a routine to extract a signature out of the entire mail body. But now i have been allotted a task to use javamail and access my gmail account and from there extract the email's body and save it in a file on my computer and then call my routine on that file so that the signature out of it is extracted. So i just needed some code to save my gmail email's body in some file on my disk. I've tried to search for it but i'm not getting something useful.

So if anyone can please provide me a working and simple code for this task to extract the email body from gmail and save it in a file on my computer, i'll really be very greatful. Thanking you...
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, first you download JavaMail. (You may already have done this.) Then you look in the "demo" folder of your download, where there is a lot of sample programs. The one you're looking for as the basis of your code is "msgshow.java".
 
Andrew Vyas
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mr. Paul. I'm very thankful that you replied and i also tried to run the msgshow.java file in the demo folder and it gets compiled nicely but when it comes the time to run, it gives me exceptions.
I am runnig it with the following command

java msgshow -T imap -H pop.gmail.com -U my_id@gmail.com -P pwd -f INBOX 1

But on doing this i'm getting the exception...

javax.mail.MessagingException: Connection timed out: connect;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
at javax.mail.Service.connect(Service.java:288)
at msgshow.mail(msgshow.java:162)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.PlainSocketImpl.connect(Socket.java:519)
at java.net.PlainSocketImpl.connect(Socket.java:469)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.iap.Protocol.<init>(Protocol.java:107)
at com.sun.mail.imap.protocol.IMAPProtocol<init>(IMAPProtocol.java:104)

at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538)
... 2 more

This is what i'm getting. I will be very delighted if you can solve this or else give me some simple code for gmail mail storage. Thanking you...
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't make the mistake of thinking that code is everything. The error message means your computer can't connect to pop.gmail.com. That's something to do with your network configuration and no amount of programming will change that. Talk to the person who connected your computer to the network and ask them what can be done.

It's possible that the network is configured to prevent you from making that connection. However your network specialist should be able to tell you that.
reply
    Bookmark Topic Watch Topic
  • New Topic