Reading mails from Hmail Server

hi all,
I am using an java mail api to read mails from a hmail server.I was successfull in reading mails and analysing it further but the problem that i face is my program could read only the recent mails ,all the remaining unread mails were not accessible from the java code.......i am attaching my code...
package mail.hmailserver;
import java.io.*;
import java.util.*;
import javax.mail.*;
public class ReadMail_frm_hmailserver {
     int c=0;
@SuppressWarnings("unchecked")
public static void main(String args[]) throws Exception {
ReadMail_frm_hmailserver mailObj=new ReadMail_frm_hmailserver();
mailObj.readMails();
public Vector[] readMails() throws Exception
     String host = "172.29.19.78";
String user = "[email protected]";
String password = "testuser1";
// Get system properties
Properties properties = System.getProperties();
// Get the default Session object.
Session session = Session.getDefaultInstance(properties,null);
// Get a Store object that implements the specified protocol.
Store store = session.getStore("pop3");
//Connect to the current host using the specified username and password.
store.connect(host, user, password);
//Create a Folder object corresponding to the given name.
Folder folder = store.getFolder("inbox");
// Open the Folder.
folder.open(Folder.READ_ONLY);
//folder.open(Folder.READ_WRITE);
Message[] message = folder.getMessages();
// String [] contents=new String[10];
Vector [] contents = new Vector[message.length];//creating array of vectors to store mails
// Vector contents1=new Vector();
System.out.println("No of mails : " + message.length);
System.out.println("subject 1 : "+message[0].getSentDate());
System.out.println("subject 2 : "+message[0].getSubject());
// System.out.println("subject 3 : "+message[2].getSubject());
// System.out.println("subject 4 : "+message[3].getSubject());
//System.out.println("-----------------");
// Display message.
for (int i = 0; i < message.length; i++) {
          c=0;
          contents[i] = new Vector(); //since vector array is an array of arrays we hav to initilize each of the content vectors
System.out.println("------------ Message " + (i + 1) + " ------------");
System.out.println("SentDate : " + message.getSentDate());
System.out.println("From : " + message[i].getFrom()[0]);
System.out.println("Subject : " + message[i].getSubject());
System.out.print("Message : ");
//System.out.println(message[i].getContent());
Multipart multipart = (Multipart) message[i].getContent();
//System.out.println(multipart.getCount());
String line = null;
for (int j = 0; j < multipart.getCount(); j++) {
//System.out.println(i);
//System.out.println(multipart.getContentType());
BodyPart bodyPart = multipart.getBodyPart(j);
InputStream stream = bodyPart.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
while (br.ready()) {         
     try {
                              //line.append(br.readLine());
          //line=line+"\n"+br.readLine();
          line=br.readLine();
          if(line.equals("NOTICE")){
                    System.out.println("entered-----------------------------exit loop");
                    //exit();
                    c++;
                    break;
          if(c==0)
          contents[i].add(line); //adding the mails line by line to the array
                         System.out.println(line);
          //System.out.println(contents[i].get(j));
     } catch (Exception e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                              System.out.println("Exception : "+e);
     //contents[1].add(line);
System.out.println();
//System.out.println(line);
// contents[i].add(line); //adding the mails line by line to the array
System.out.println();
// folder.close(true);
//store.close();
//System.out.println(contents.length);
//System.out.println(contents[0].get(0));
//System.out.println(contents[0].);
return contents;

You might want to use IMAP to read mail from hMail Server, if you keep messages on server. It has a lot more features for managing messages on server.
A lot of POP3 implementations (both client and server side) will automatically delete retrieved messages. I don't know exactly what JavaMail does in that regard, nor of hMailServer, but I do know some mailservers out in the wild will ALWAYS delete mails retrieved with POP3.

Similar Messages

  • Mail 2.1.1: Can't read mails from Exchange server

    Effect: *Mail 2.1.1* contacts the Exchange server successfully, which I checked with the operator, looking directly over his shoulder, but Mail 2.1.1 does not load any e-mails. Mail 2.1.1 loads down mails from another server with unknown software (gmx.de) successfully.
    Mail 2.1 works nicely with absolutely identical settings with both mail servers
    I am using Mail 2.1.1/MacOS 10.4.10 on my G4 and MacBook Pro, Mail 2.1/MacOS 10.4.10 on my G5.

    No solution found - works again. Please no questions.

  • Reading mails from Zimbra inbox.

    Hi,
    I have a basic program to read the inbox of a zimbra mail user.
    i have supplied the necessary information like username passwd,
    Can someone please tell me what is the pop server required for the Zimbra mail client.
    i know it is somethign do with the LDAP. but how do i find tht out?

    You might want to use IMAP to read mail from hMail Server, if you keep messages on server. It has a lot more features for managing messages on server.
    A lot of POP3 implementations (both client and server side) will automatically delete retrieved messages. I don't know exactly what JavaMail does in that regard, nor of hMailServer, but I do know some mailservers out in the wild will ALWAYS delete mails retrieved with POP3.

  • Error in reading the mails from POP3 server

    Hi,
    I am reading mails from the POP3 server using UTL_TCP package. I am able to retrieve .txt & .doc attachments successfully.
    I am facing an error when I try to retrieve an attachment with a very long name (irrespective of the file type). Also, I am unable to retrieve .docx, .xls, .xlsx file types. I noticed similarity in the reasons for the error I am getting. I realized that if I try to retrieve an attachment with a very long file name or any of the above mentioned file formats (.docx, .xls, etc.), the "name" attribute of the attachment goes to the next line and hence I am going wrong somewhere in parsing that line.(The complete line comprises of : Content-Type: application/vnd.openxmlformatsofficedocument.wordprocessingml.document; name="test_attachment.docx")
    I realized this pattern by doing executing Telnet commands to retrieve emails from POP3 server.
    I am trying to parse the line I am talking about in the following manner:
    IF line LIKE 'Content-Type: %;'
                   THEN
                        IF line LIKE 'Content-Type: %; name=%'
                        THEN
                             PIPE ROW (line);
                        ELSE
    -- This should only print the "Content-Type". But I get an error (pasted below) at this point
                             PIPE ROW (line);
    -- To read the "name" attribute which comes on the next line. But this line never gets executed since I get an error in the previous statement
                             BYTES := UTL_TCP.available (socket);
                             BYTES := UTL_TCP.read_line (socket, line);
                             PIPE ROW (line);
                        END IF;
    The error I get is :
    ERROR:
    ORA-29261: bad argument
    ORA-06512: at "SYS.UTL_ENCODE", line 29
    ORA-06512: at "SYS.UTL_ENCODE", line 251
    ORA-06512: at "SCOTT.POP3", line 117
    Message was edited by:
    Monk
    Message was edited by:
    Monk

    Hi,
    Try to manually download the file from application server using standard transactions, and than check how many records are you able to download from app. server.
    I guess there might be something wrong with the format of 583rd record, which makes sap assume that the file has come to an end.
    Hope this will help you.
    Regards,
    Vinit...

  • HT4859 After the i-cloud server issue Nov 26, 2012, I had to change some mail account settings to get my i-cloud mail to work again.  However, all of my received e-mails are gone.  How do I retrieve my e-mails from the server?

    After the i-cloud server issue yesterday, November 26, 2012, my i-cloud mail account on my Macbook Pro stopped receiving mail.  I changed some mail account settings to fix the issue, and was able to start receiving e-mails.  However, all of my historical e-mails are gone.  How do I retrieve all of my old e-mails from the server?

    What settings did you change, what were the changes, have you visited www.icloud.com to see what mail is actually there? and do you have a backup?

  • How to fecth the contents of a mail from the server by using jsp

    hi
    Can any body tell me how to fetch the contents of mail from the server by using javamail api...please send me code if some one have
    bye.

    hi
    Can any body tell me how to fetch the contents of mail from the server by using javamail api...please send me code if some one have
    bye.

  • The attempt to read data from the server failed

    Today I was looking into an error with several IMAP accounts in Apple Mail:
    +The attempt to read data from the server "<<servername.tld>>" failed.+
    At first I thought this was an Apple Mail problem, as the accounts in question seemed to work just fine when not used in combination. One possible answer to this problem is rather short:
    Apple Mail uses IMAP caching, which uses more than 4 connections at the same time to the mail server. Some mail servers (like courier-imap in its default configuration) do not allow that much connections from the same IP address. The more accounts you are trying to connect to at the same time raises this number of connections. Meaning while you could probably check one account for new mails, the second will ultimately fail for no obvious reasons. The only solution to this problem is to raise the connections allowed by your IMAP server software. this solution only applies to people who have root access to their mail server.
    in courier-imap you have to edit /etc/courier-imap/imapd
    and change MAXPERIP=4 to a higher number (5 to 10 times the number of accounts you want to check simultaneously)
    and change MAXDAEMONS=40 to a higher number (with only one user 200 might work, whereas if you serve multiple users, something like 500 or higher might be better suited).
    of course increasing the numbers increases load on your server. this is why there are these restrictions in place.

    MY SOLUTION REPOSTED FROM ANOTHER THREAD:
    I've just solved a similar issue.
    I have a dedicated server running Plesk 9.5 and when I upgraded to iLife 11 and Snow Leopard this error appeared. I could quickly click "get mail" and I'd get all my mail, but only 3-4 of my 9 mail accounts would connect. Theo others would have the error:
    "The server error encountered was: The attempt to read data from the server..."
    I found solutions for those using IMAP mail:
    modify the /etc/courier-imap/imapd configuration file and change MAXDAEMONS from 40 to 80 and MAXPERIP from 4 to 40. This allows all the machines behind my home firewall to connect to multiple accounts on the e-mail server with mailbox caching enabled.
    I'd made this change on my server but it didn't seem to have any effect. It dawned on me that I'm using POP, not IMAP. So I found in /etc/courier-imap/pop3d the same settings. I changed the MAXDAEMONS from 40 to 80 and MAXPERIP from 4 to 40 and voila, all my connections concurrently worked.
    This has taken me more than two days to fix and I hope posting this helps someone else with the same issue.

  • Ever since iOS 7 was installed on my phone it keeps fetching all and any e-mail from my server and it is taking up tp as much as 2.5 GB even after I delete the messages! Now after a complete wipe and restore it is happening all over

    ever since iOS 7 was installed on my phone it keeps fetching all and any e-mail from my server and it is taking up tp as much as 2.5 GB even after I delete the messages! Now after a complete wipe and restore it is happening all over again why can't the techs at apple fix this defective program??????????????

    ever since iOS 7 was installed on my phone it keeps fetching all and any e-mail from my server and it is taking up tp as much as 2.5 GB even after I delete the messages! Now after a complete wipe and restore it is happening all over again why can't the techs at apple fix this defective program??????????????

  • Read E-Mail Actionblock -Unable to read mail from Mailserver

    Hi,
    As a part of business requirement I need to write a transaction which picks the attachment from a particular mail on a server on a scheduled basis.
    I am getting the below error while trying to connect to the server
    [INFO ]: ReadMail: Connecting To: xxxx.yyyy.mycompany.com
    [ERROR]: ReadMail error: Connect failed; nested exception is: java.net.ConnectException: Connection refused: connect+
    [ERROR]: ACTION FAILED: End Action ReadMail_0 :
    But with the same credentials I am able to send mail from xMII using the Send mail action block.So this signifies that I am using the right MailServer name.
    Is this the problem with the firewall with the server ? or
    Will there be different MailServer name for receiving and reading mails?
    How to know which port number to be used?
    Did any one faced this problem before?
    Appreciate your help
    thanks
    Raj

    Hi,
    Im also having problems with reading mails from mailserver.
    When I execute the transaction the action block Read Mail return me the following error:
    [ERROR] [ReadMail]Unable to read mail Exception: [unicode-1-1-utf-7]
    Could anybody help me?
    P.S.: Im using the imap4 protocol.
    Thank you!
    Edited by: Thiago Barros on Jul 29, 2010 5:15 PM

  • Server error: "The attempt to read data from the server '(null)' failed"

    Multiple times during each day my client (Mail.app) puts up a little exclamation mark "!" next to the mail account hosted on our Leopard Server. Clicking on this little alert icon pops up a message that reads:
    +There may be a problem with the mail server or network. Verify the settings for account “Leopard Server Account” or try again.+
    +The server returned the error: The attempt to read data from the server “(null)” failed.+
    I can make the "!" go away by choosing Mailbox>Synchronize>Leopard Server Account. And everything seems peachy but it inevitably pops up again in another hour or two. It's annoying because I'm not sure if mail is getting through or not when the "!" is up.
    Any ideas why this is happening?

    MY SOLUTION REPOSTED FROM ANOTHER THREAD:
    I've just solved a similar issue.
    I have a dedicated server running Plesk 9.5 and when I upgraded to iLife 11 and Snow Leopard this error appeared. I could quickly click "get mail" and I'd get all my mail, but only 3-4 of my 9 mail accounts would connect. Theo others would have the error:
    "The server error encountered was: The attempt to read data from the server..."
    I found solutions for those using IMAP mail:
    modify the /etc/courier-imap/imapd configuration file and change MAXDAEMONS from 40 to 80 and MAXPERIP from 4 to 40. This allows all the machines behind my home firewall to connect to multiple accounts on the e-mail server with mailbox caching enabled.
    I'd made this change on my server but it didn't seem to have any effect. It dawned on me that I'm using POP, not IMAP. So I found in /etc/courier-imap/pop3d the same settings. I changed the MAXDAEMONS from 40 to 80 and MAXPERIP from 4 to 40 and voila, all my connections concurrently worked.
    This has taken me more than two days to fix and I hope posting this helps someone else with the same issue.

  • Attempt to read data from the server failed...

    I'm getting the following error on one of my email accounts:
    +There may be a problem with the mail server or network. Verify the settings for account “[my account]” or try again.+
    +The server returned the error: The attempt to read data from the server “[my account]” failed.+
    I'd like to find out more about the error, so that I can start to track this down and see if there is a problem with the mail server settings, or if the problem is on my end.
    I don't see any reference to this error in the logs – would it be somewhere else?

    I've just solved a similar issue.
    I have a dedicated server running Plesk 9.5 and when I upgraded to iLife 11 and Snow Leopard this error appeared. I could quickly click "get mail" and I'd get all my mail, but only 3-4 of my 9 mail accounts would connect. Theo others would have the error:
    The server error encountered was: The attempt to read data from the server...
    I found solutions for those using IMAP mail:
    modify the /etc/courier-imap/imapd configuration file and change MAXDAEMONS from 40 to 80 and MAXPERIP from 4 to 40. This allows all the machines behind my home firewall to connect to multiple accounts on the e-mail server with mailbox caching enabled.
    I'd made this change on my server but it didn't seem to have any effect. It dawned on me that I'm using POP, no IMAP. So I found in /etc/courier-imap/pop3d the same settings. I changed the MAXDAEMONS from 40 to 80 and MAXPERIP from 4 to 40 and voila, all my connections concurrently worked.
    This has taken me more than two days to fix and I hope posting this helps someone else with the same issue.

  • I can't access my mail from the server!!!

    I am having trouble retrieving mail....I click on "Get Mail" and nothing happens. When I select the inbox and Get Info, it shows that there are a number of new emails on the server, yet my Mail program does not want to retrieve them. I checked to see if my account was enabled (under Preferences) and it is....I don't understand what the problem is...this is happening in a networked office of 10 other macs, and only one other person is having this exact same problem. very weird. internet works fine.
    any suggestions? I'm about to download a new mail program like entourage if this keeps up.
    thanks,

    POP account.
    We own Entourage already, so that isn't a problem.
    Right now we're using www.mail2web.com as a temporary solution, but that isn't really practical for a professional architecture firm where email records are essential to our business.
    I would love to keep using Mail, I really have no idea how to fix this problem. I don't know why it is only happening to 2 of our 10 computers, there is no difference in the setup of any of them, and this started mid-morning, so I know that the users did nothing to the settings. It just stopped wanting to pick up mail from the server.
    File size does not seem to matter, because one of the computer's mailboxes has about 10,000 emails saved, and the other has about 20, and they are showing the exact same behaviour. It is really strange!

  • How to remove my icloud mail from icloud server ?

    how to remove my icloud mail from icloud server ?

    If you don't want to keep it, select it, on the iCloud website Mail page click the Trash icon in the toolbar to move it to the Trash, then click the cogwheel icon at top right and choose 'Empty Trash'. Or in the Mail application drag the messages to the Trash and from the Mailbox menu choose 'Erase deleted items' then 'iCloud'.
    If you want to keep it, in the Mail application drag the messages to another mailbox under 'On My Mac'.

  • HT201320 when my phone goes and gets my mail, can i get it to remove the mail from the server.

    when my phone goes and gets my mail, can i get it to remove the mail from the server.

    Only if it's a POP3 server. IMAP and Exchange synchronize the server and all clients.

  • Sending Mail from EBP Server

    Hi,
    I am trying to send external mail from EBP server through the function module SO_NEW_DOCUMENT_ATT_SEND_API1. I have passed similar kind of values to the parameter which I have used for R/3 while using the same function module. In R/3 server the function module is working fine but not in EBP. I am new in EBP. Does this function module work fine in EBP ? If not can someone provide me any Function Module name through which I can send external mail ?
    Thanks in advance,
    Achirangshu

    Hi,
      Try the FM "SO_DOCUMENT_SEND_API1".
    BR,
    Disha.
    Pls reward points for helpful answers.

Maybe you are looking for

  • JTree remove expand/collapse cross button...??

    Hi all, I have forbidden tree collapsing (by default it is fully expanded), and I want to remove expand/collapse cross buttons that actually are used to expand/collapse tree nodes. Is it possible and can anyone give me advice how i can do this. Thank

  • IWeb legibility problems ??

    I created a website using iWeb 08 cutting and pasting from MS Word Lucida Grande font text on a variety of pages. The pages look good when observed through Safari, Netscape, Camino, and Firefox on my computer. They look good to almost everyone else t

  • Mac Pro power issue...

    Wondered if anyone else had this issue. I have a Mac Pro from mid 2008. Recently, it has done the following: - From a 'cold' start, it will power up for 3-4 secs and then power off again. It will not reach the grey screen. - It will only fully power

  • I pod ID and passwords

    I just purchased an i pod touch and can't believe the problems with securing and ID and password. It is the most incompetent system i have ever encounterd with any device. I registered the thing, gave my password and e-mail address and they snd me a

  • Error creating filesystem dm_crypt (Error creating filesystem lvm-lv)

    I'm new to Arch and I've tried to to a new installation on my notebook. I followed the "Official Arch Linux Installation Guide", chapter "Manually configure block devices, filesystems and mountpoints" in order to create my encrypted disk setup. Creat