I use javamail to access the gmail account but i could not mail from inbox

import java.io.*;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
class GetMessageExample {
public static void main(String args[]) throws Exception
String s;
String host = "216.239.118.70";
String username = "user";
String password = "pwd";
// Create empty properties
Properties props = new Properties();
// Get session
Session session = Session.getDefaultInstance(props, null);
// Get the store
Store store = session.getStore("pop3");
store.connect(host, username, password);
// Get folder
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));
// Get directory
Message message[] = folder.getMessages();
for (int i = 0, n = message.length; i < n; i++) {
System.out.println(i + ": " + message.getFrom()[0] + "\t" +
message[i].getSubject());
System.out.println("Read message? [YES to read/QUIT to end]");
String line = reader.readLine();
if ("YES".equalsIgnoreCase(line)) {
System.out.println(message[i].getContent());
} else if ("QUIT".equalsIgnoreCase(line)) {
break;
// Close connection
folder.close(false);
store.close();
i get the following error ....
Exception in thread "main" javax.mail.MessagingException: Connect failed;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:148)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at GetMessageExample.main(Main.java:25)
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.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.pop3.Protocol.<init>(Protocol.java:81)
at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:201)
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:144)
... 3 more
please help me in this....
with regards,
mega...

Here is the code
import java.io.*;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class GetMessageExample {
     public static void main(String args[]) throws Exception
     String s;
     String host = "pop.gmail.com";
     String username = "user";
     String password = "pass";
     //     Create empty properties
     Properties props = new Properties();
//     Get session
     Session session = Session.getDefaultInstance(props, null);
//     Get the store
     Store store = session.getStore("pop3s");
     store.connect(host, username, password);
//     Get folder
     Folder folder = store.getFolder("INBOX");
     folder.open(Folder.READ_ONLY);
     BufferedReader reader = new BufferedReader(new InputStreamReader(
     System.in));
//     Get directory
     Message message[] = folder.getMessages();
     for (int i = 0, n = message.length; i < n; i++) {
System.out.println(i + ": " + message.getFrom() + "\t" + message[0].getSubject());
     System.out.println("Read message? [YES to read/QUIT to end]");
     String line = reader.readLine();
     if ("YES".equalsIgnoreCase(line)) {
     System.out.println(message[i].getContent());
     } else if ("QUIT".equalsIgnoreCase(line)) {
     break;
//     Close connection
     folder.close(false);
     store.close();
Message was edited by:
syberwarez

Similar Messages

  • TS3988 My icloud account is not verifying it says check my mail witch I have done and I get a message say your iPhone for has been used to set up and Icloud account but still can not use the icloud can anybody help me.

    My icloud account is not verifying it says check my mail witch I have done and I get a message say your iPhone for has been used to set up and Icloud account but still can not use the icloud can anybody help me.

    Be sure you are checking the email account that you used to set up the Apple ID you used to create the iCloud account.  Also, be sure to check your spam/junk folder as well as your inbox.  The email you should receive looks like the image below.  When you get it, click the Verify Now link.
    If it still isn't there, try going to https://appleid.apple.com, click Manage your Apple ID, sign in, click on Name, ID and Email addresses on the left, then to the right look for a link to resend the verification email.

  • I just recently downloaded iTunes and whenever I try to access the store It says "iTunes could not connect to the iTunes Store. An unknown error occurred (0x80096004)

    I just recently downloaded iTunes and whenever I try to access the store It says "iTunes could not connect to the iTunes Store. An unknown error occurred (0x80096004). I have windows xp and it's running on service pack 2. I have downloaded and redownloaded iTunes many times. I'm getting very frustrated!  Please help!

    I have the same error for Windows Vista.  I read all the community posts and followed the suggested fixes including numerous uninstalls and installs, clearing cache, choosing various SSL TL options, turning off all spyware and nothing has worked.  My internet works fine for all my other programs so not sure what is going on with Itunes.  I will not buy anymore products through
    Apple Itunes.

  • I have backed up my iPad  using iTunes to windows 8 Lenora laptop but I could not find my files and play video files  in my laptop.

    I have backed up my iPad  using iTunes to windows 8 Lenora laptop but I could not find my files and play video files  in my laptop

    You cannot access files in the backup on your computer.
    Do you mean that you synced with iTunes and transferred your purchased videos and app documents? If that is what you mean, what videos are you talking about? If they are videos that you took with the iPad, they do not sync to iTunes. What files?
    What exactly are you trying to do? Details please.

  • I have several accounts in thunderbird & now my delete message button will not work on the gmail account but does on the other non gmail accounts

    I have a group gmail account which has been working fine in Thunderbird until this week. I have several other earthlink accounts also.
    They are all working fine, but the gmail account is very slow now receiving and sending emails. The delete button to remove an email also will not work for the gmail.
    any ideas?
    thanks

    What is your anti-virus software?

  • I had an unauthorized purchase on my old apple ID so I created a new one since the old one had been deactivated and now I cannot update any of my apps, I have read that the apps will be tied to the old account but I do not want to delete/lose their data

    I had an unauthorized purchase on my old apple ID so I created a new one since the old one had been deactivated and now I cannot update any of my apps, I have read that the apps will be tied to the old account but since the old one was deactivated I cant update them and I do not want to delete/lose their data, re download, and start all over again. Is there anyway to go around this issue?
    thanks

    Ask Apple to re-enable it. I had an unauthorized purchase last October. They disabled my account until the problem was solved. However, I asked them to reopen it, and they just asked me to provide some security information (billing address, a recent purchase you made, etc.), and then they re-enabled it.

  • GW User account hanging on opening any mail from inbox

    Groupwise user account is hanging when a mail from mailbox is being opened. same problem when it is being accessed from different systems. repaired but still no use. Increased the mailbox size but still no use. please help me to sort out the issue

    Hi,
    Kindly explain exactly what repairs have been done on the mailbox. Thanks.
    Looking forward to hearing back from you.
    Cheers,

  • My iPod touch will access the app store, but it won't install from it.

    I was given a used iPod Touch, and I don't know any of its history. Eveything was working fine, and then one day I tried to install from the App store and it won't work at all. I can press the "install" button, but then the app store will just close without even setting up an icon on the home screen. If I try to install the same app again, there's no record that I had tried to install it previously. I use this for school, so this is really annoying.
    PS: I am a clueless Windows user, and have never owned and i-anything until now. =)

    Try resetting the iPod. Nothing will be lost
    Reset iPod touch:  Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.

  • HT1277 When I delete email from my actual hotmail, yahoo and gmail accounts online, it does not delete from my MacBook Pro Mail accounts that I created for hotmail, yahoo, gmail. I thought sync'ing these accounts would do this. Please help :-)

    MacBook Pro 13.3/2.3/2X2GB/320/SD-USA with Mac OS X v10.5
    I've set up my Mac - Mail with my yahoo, gmail and hotmail accounts and can successfully send and receive mail. However, when I go online to my actual yahoo, gmail and hotmail accounts to delete unwanted emails or to move those emails into subfolders, my Mac - Mail is not updated. How do I do this?
    Also, if you can help show me how to view my hotmail folders in Mac - Mail, I would greatly appreciate it.
    Thanks!!
    Tessy

    Is it POP or IMAP? - see Mail/Preferences/Accounts - highlight an account and see what the Type is.
    Try Mail/'menu bar'/Mailbox/'Take All Accounts Online'

  • I have changed the Apple ID in the main ID settings but my iPhone does not recognise this. I have added this to the main account but it does not accept the password.

    I changed from iPhone 4s to iphone 5s. While doing the set up, I also renamed my Apple ID. However, allowed the old Id to be an alternate. However, now my iphone refuses to accept the password - neither the new one or the old one. What do I do?

    Hello, pryiyer.  
    Thank you for visiting Apple Support Communities.  
    I would recommend reaching out to our Apple ID Account Security team to assist you with this issue.
    Apple ID: Contacting Apple for help with Apple ID account security
    http://support.apple.com/kb/HT5699
    Cheers,
    Jason H.

  • HT4623 i am using iphone 4 running on ios 6 but i could not see an software update option in my settings ....please can u help

    i am not able to see software update option in my settings     
    i am using iphone4 ruuning on ios 6.0.1

    Your iOS version is probably too old to support software update.  You must update using iTunes on your computer.
    Make sure your iTunes on the computer is current.  Plug your iPhone into iTunes.  Let it sync.  Then choose "Check for Updates..." from the iPhone's summary tab in iTunes.  That should od it for you.

  • We want to automate Iphone mobile app's, can anybody give the details of the Mobile Automations tools that are certified the by the Apple, here i am having some of the tool names but i could not be able to figure out whether Apple has cerified those tools

    Hi All,
    We are planning to regress IOS mobile app that were developed in our organization with the help of Mobile Automation tools that were available int he market both commericial as well as non-commercial. Can anyone please provide us with list of tool that were certified by the apple to use for our needs in the functional as well as regression of the developed applications. I am having a list of tools that we got from the net when browsed,
    UIAutomation
    TestFlight
    SeeTestMobile
    M-eux
    NativeDriver
    Frank
    FoneMonkey / Mokey Talk
    DeviceAnyWhere
    KIF
    LessPainful
    iCuke
    UISpec
    Zap-Fix
    TestQuest
    T-Plan Robot
    Sikuli
    TestPlant
    Can any one of you let me know from the list as what are the tools that was certified the apple, apart from this list anyother tools that i may miss from the list that were certified by the Apple
    Revert back ASAP
    Wating for the reply

    Hi All,
    We are planning to regress IOS mobile app that were developed in our organization with the help of Mobile Automation tools that were available int he market both commericial as well as non-commercial. Can anyone please provide us with list of tool that were certified by the apple to use for our needs in the functional as well as regression of the developed applications. I am having a list of tools that we got from the net when browsed,
    UIAutomation
    TestFlight
    SeeTestMobile
    M-eux
    NativeDriver
    Frank
    FoneMonkey / Mokey Talk
    DeviceAnyWhere
    KIF
    LessPainful
    iCuke
    UISpec
    Zap-Fix
    TestQuest
    T-Plan Robot
    Sikuli
    TestPlant
    Can any one of you let me know from the list as what are the tools that was certified the apple, apart from this list anyother tools that i may miss from the list that were certified by the Apple
    Revert back ASAP
    Wating for the reply

  • Iphone4 - Two Gmail Accounts - Outgoing server does not work anymore

    I started using my private Gmail account on my Iphone and everything worked fine (having found help in Youtube videos about how to set up Ingoing/Outgoing server).
    Now I added my Gmail account from work (ends on .nl instead of .com - Dont know if that matters). I can now access both inboxes but I cannot send emails from BOTH accounts. I then deleted the new account but still cannot send emails from my first account anymore.
    I found that under "settings->Mail,Contacts,Calendars->Gmail Account->AccountInfo->OutgoingMailserver SMTP" I now have a primary server which seems to connect to my first account and several "other SMTP server" which contain either details of the first account or the second account (which I actually deleted aleady).
    Should I delete those additional servers? How can I do this? Does anyone have experience with this kind of issue?
    Thanks a lot in advance.

    I did put all the informations and still it does not work telling that these informations are not right!!!!
    HELP please

  • I need to get into my old account and get my addresses and then cancel the old account but can not get into it. Had to change my user name when I moved and now I can't get into Firefox. Can't remember the old password. What to do??

    I moved during the summer. I changed to highspeedand & when I set my computer up it told me that my email address was already in use so I had to change it(????) I changed from jkady to [email protected] I tried to change it on firefox but it would not except the new name and I could not get into my old account.I need all my addresses and would like to cancel the old account but I can not get into it. This is very frustrating!!!!! I need my addresses!!!!!!!!

    I logged in changed the primary E-Mail address to a different one, vertified it then tried to log in it said either to send an E-Mail to veritify again or to do my security questions, so I choose to do the security questions and put in my Birthday like it asked and it said that it was wrong and I had to authenticate it to get in, why is it so hard to just set up a Apple ID really though!
    So I tried the E-Mail to and it has not sent me an E-Mail then I tried to log in again and it has locked me out of my account so I try to recover my password and it gave me the same options to get my password back and both options are doing the same as before, it says I don't know my on birth date or it is wrong or needs authenticate it, then the E-Mail doesn't come through!
    This is just stupid now.

  • Media Encoder - encoding failed - could not read from the source

    Using PPCC, AME queued jobs all fail with the message "Encoding failed. Could not read from the source".
    But doing a simple export works perfectly.

    I recall quite a few other threads about this.  Do a forum search.

Maybe you are looking for

  • Problem with bankapp sample application.

    I'm trying to configure and run the bankapp application for Tuxedo 8.0 under HP-UX, but I'm getting errors to connect to database. I'm using the RM=TUXEDO/SQL and when I run the script crbank I get the the following error messages: sql: Operation 'cr

  • How do I use my wireless keyboard with my iPad?

    Not sure it can even be done, but I think I saw it being used.

  • HOW: To save/refresh data from different forms but in same session

    Hi I have 2 screens Screen-1      Tabluar form with 10 rows and each row corresponds to one edit image Screen-2      Forms type form with multiple text items and list items and one OK and cancel button      If I click on OK button, whatever I enter i

  • ABAP Runtime Error - " Reshedule Periodic jobs"

    Dear Friends, I got around 120 ABAP runtime error in PRD system regularly(Daily) for the period of 4.40 AM to 5.18 AM. How can i solve following ABAP Runtime Error, Pls give me suggession. SM21 - System Logs: Client           :     000 User          

  • Validation GGB0

    Hello Can anyone clarify how many validation can we have in a company code? there is already 1 validation in a company code for TDS i.e. line item validation for entering Business place & now i want to create a line item validation for Cash Payment a