Sorting mails by date

Hi,
I am having trouble using javamail to read messages from a pop server.
I can get the messages, but they do not seem to be sorted by date.
This is a problem because if there are lots of messages on the server but I want to read just the most recent one, I need to download all the messages (or at least the envelope of all messages) to determine which one is the most recent.
Is there a way to access a list of messages sorted by date ?
Thanks for your help
Here is the code I use :
String popHost = ...
String id = ...
String pwd = ...
Properties props = new Properties();
Session popSession = Session.getDefaultInstance( props, null );
popSession.setDebug( false );
Store popStore = popSession.getStore( "pop3" );
popStore.connect( popHost, id, pwd );
Folder folder = popStore.getFolder( "inbox" );
folder.open( Folder.READ_ONLY );
int newMessageCount = folder.getNewMessageCount();
int totalMessageCount = folder.getMessageCount();
Message[] lastMessages = null;
if ( totalMessageCount > 4 ) {
messages = folder.getMessages( 1, 5 );
}

If you'd searched through the forum you would have found this thread which might help.
https://community.bt.com/t5/Email/Sort-by-sender/td-p/1480044

Similar Messages

  • IPhone Mail.app does not sort mails by date

    I've just copied about 3000 old mails from a POP3 account to my Gmail account (IMAP). This was done through OS X mail.app, which just works perfect both in the OS X Mail.app and in the Gmail web interface.
    The problem is that the Mail.app on my iPhone seems to sort the mails by some kind of mail ID so all the copied mails appears first in the Mail.app. I can't find any way to sort the mails by their date, which I guess will solve the problem.
    If there is missing importing information about the problem please let me know so I can supply with more information.

    This is a known issue with gmail. I found this in their FAQ:
    "Messages uploaded or copied into Gmail using IMAP may display the wrong date in your inbox or other labels."
    See http://mail.google.com/support/bin/answer.py?answer=82365&topic=12922
    Apparently "The correct dates should appear in conversation view." applies only to web browsers and not the iPhone Mail app.

  • Shortcut for Sorting Mail

    Hi,
    I am pleased that under Mountain Lion there is now a quick way to get to the top of your inbox, however, are there any shortcuts for sorting the mail by date, sender, etc.?  I frequently need to re-order the inbox and whilst the dropdown menu is available it is quite a small dropdown and can be a bit fiddly.  If there was keyboard shortcut assigned then I would also be able to add a gesture as well, but it seems the only way to chagne the order is via the dropdown menu.
    Any suggestions?
    Thanks

    Use your own Comparator which knows how to handle the four fields.
    or let your Object implement the Comperable interface
    public class MyComparator implements Comparator
      public int compare(Object obj1, Object obj2)
         int result = 0;
         if( obj1.f1 == obj2.f1  )
           // something similar with f2
         else
            result = obj1.f1 < obj2.f1 ? -1 : 1;
         return result;
    }You can than use
    file:///usr/local/share/doc/j2sdk-1_4_1/docs/api/java/util/Arrays.html#sort(java.lang.Object[],%20java.util.Comparator)
    to sort an Object Array using this comparator

  • How can I sort lines of data (alphabetically) in the new pages 5.0?

    How can I sort lines of data (alphabetically) in the new pages 5.0?
    It was very simple to do in the previou version of pages.

    I'm not sure why people are torturing themselves with Pages 5 given the nearly universal outcry on this forum and the incredibly negative reviews elswhere, such as the App Store.
    Pages 4.3 should still be in an iWorks folder within your Applications folder.  Just use that.
    Please remember to tell Apple what we need from them at:
    http://www.apple.com/feedback/pages.html

  • How Can I put an Artists Live Albums in a separate folder, so they sort by "Concert Date" in iTunes and do not "intermingle" so to speak with Studio Albums?  Is this possible?

    How Can I put an Artists Live Albums in a separate folder, so they sort by "Concert Date" in iTunes and do not "intermingle" so to speak with Studio Albums?  Is this possible?
    That is about the best way I can phrase my question.
    I put year/month/date at the beginning of a show, hoping for them to sort by date and I get mixed results.
    Would creating a Folder within the Artists' existing folder  that said "Pearl Jam Live", inside the "Pearl Jam" folder in iTunes Media help this "Date Sorting Issue"?
    Thank you.

    Or is there a way to go through aperture to make a new reference library that I can move the masters into later?
    you do not move the masters into a references library - you turn your current library into a referenced library.  As Terence Devlin said:
    File -> Relocate Masters
    What you should set up:
    Select a folder, where you want to store your referenced files - probably on an external drive.
    Decide on a hierarchical folder structure inside this folder - that is completely up to you.
    Select a project from your library and use the command "File -> Relocate Masters/Originals" to move the original image files to the folder where you want to go them to. Only take care not to send two projects to the same folder.
    Alternatively, if you do not care about the folder structure Aperture will use, select all images at once from the "Photos" view and let Aperture decide how to assing the folders - in the "Relocate Originals" dialoge you can specify a subfolder format.
    Regards
    Léonie

  • How do I delete duplicate songs in my iTunes? I have hundreds and I don't want to delete them one by one. They were all added on the same date, so sorting by the date won't help.

    How do I delete duplicate songs in my iTunes? I have hundreds and I don't want to delete them one by one. They were all added on the same date, so sorting by the date won't help.

    Hi, if this is in regards to your library simply open up itunes and do the following steps:
    Click File
    Scroll down to "show duplicates"
    A list will then appear of your duplicate song titles.
    Be sure to CAREFULLY review each song to make sure it is a duplicate ( as I have some music that is the same song but live, acoustic etc...)
    Proceed to manually delete each song from the list and leave alone any song that you wish to keep.
    Best of luck,
    Cait

  • In V_V2 the role of Sort Item by date of creation and Sort by delivery date of earliest schedule line for the Sales Orders when Material is out of Stock.

    Hi All,
    Good Morning,
    I am working on once Incident for Re-Scheduling Program V_V2 where the user has requested us to change the criteria for determining the priority of Sales Document based on Sort Item by date of creation. Currently they are using the Sort by delivery date of earliest schedule line in the Variant.
    I would like to know the role these both options play in the Re-Scheduling program V_V2. I would like to know the impact of both of them and the kind of testing I need to perform to study the behaviour of Sales Orders especially when the material is out of stock?
    Please explain with help of examples.
    Thanks
    Farhan.

    This is not that simple that an example would explain how this transaction works but I'll give you some examples.
    Material A has SO1 and SO2 of 10KG each, stock is 20KG so both quantities are confirmed at today. A stock recount determines a reduction to 5KG. This program would change confirmed quantity of SO1 to 5KG and SO2 to 0KG if:
    Creation date of SO1 is older then SO2 in strategy 1
    1st delivery date of SO1 is smaller then SO2 in strategy 2
    Material B has SO1 and SO2 with 10KG each but no quantity confirmed, stock is 0KG. A prodution adds 15KG to stock. The program would change confirmed quantities of SO1 to 10KG and SO2 to 5KG if:
    Creation date of SO1 is older then SO2 in strategy 1
    1st delivery date of SO1 is smaller then SO2 in strategy 2
    I'm assuming a specific configuration, there are many other scenarios possible.
    regards,
    Edgar

  • Some photos are not sorted correctly by date

    I just imported some photos from my friends camera who were on the same trip. However, I noticed that a couple (not all) of his photos are not sorted correctly by date in the Event. A photo from day 3 somehow comes before the photos from day 2. I checked the extended information and the dates on the photo are correct. Has anyone had this problem and know of a solution? Thanks.

    It might be of some help to delete the photo cache. Please see this link - http://support.apple.com/kb/TS1314

  • Is there a better way to sort mail folders?

    Is there a way to sort mail folders the way I want them rather than alphabetical?

    Sumo23 wrote:
    Is there a way to sort mail folders the way I want them rather than alphabetical?
    no.

  • How to use XmlModify to sort the XML Data?

    Hello,
    I saw some examples explain how to use XmlModify in BDB XML package. I want to sort the XML data by several elements but my Java program could not work correctly.
    <CustomerData>
    <Transaction>
    <DLSFIELDS>
    <ADR_PST_CD>12345</ADR_PST_CD>
    <CLT_IRD_NBR>002</CLT_IRD_NBR>
    </DLSFIELDS>
    </Transaction>
    <Transaction>
    <DLSFIELDS>
    <ADR_PST_CD>12345</ADR_PST_CD>
    <CLT_IRD_NBR>102</CLT_IRD_NBR>
    </DLSFIELDS>
    </Transaction>
    // many nodes like transaction ...
    </CustomerData>
    My XQuery script was executed successfully in the shell. The script looks as follows:
    "for $i in collection('sample.dbxml')/CustomerData/Transaction order by xs:decimal($i//ADR_PST_CD), xs:decimal($i//CLT_IRD_NBR) return $i".
    The Java code :
    // create XmlManager
    XmlManager manager = // ...;
    // open XmlContainer
    XmlContainer container = // ...;
    XmlQueryContext context = manager.createQueryContext(XmlQueryContext.LiveValues, XmlQueryContext.Eager);
    XmlQueryExpression expression = manager.prepare("for $i in collection('sample.dbxml')/CustomerData/Transaction order by xs:decimal($i//ADR_PST_CD),xs:decimal($i//CLT_IRD_NBR) return $i", context);
    XmlModify modify = manager.createModify();
    XmlUpdateContext uc = manager.createUpdateContext();
    XmlDocument xmldoc = container.getDocument("sample.xml");
    XmlValue value = new XmlValue(xmldoc);
    long numMod = modify.execute(value, context, uc);
    System.out.println("Peformed " + numMod     + " modification operations");
    Could you point out the errors above or offer some suggestion?
    Thanks.

    I have other question of the sorting issue. Here are a large XML need to sort so I have to split it to multiple small XML files. After importing these files, I will use the XmlModify and XQuery to sort them. I'm not clear on the multiple XML files processing.
    1. Can the BDB XML ensure that all these XML files were sorted or how to update all documents with same logic.
    2. If I want export all these sorted documents, how can I ensure these files processed in sequence? Which document needs process first?
    The export method:
    public void export(String outputfile)throws Exception{
    final int BLOCK_SIZE = 5 * 1024 * 1024; // 5Mb
    try{
    File theFile = new File(outputfile);
    FileOutputStream fos = new FileOutputStream(theFile);
    byte[] buff= new byte[BLOCK_SIZE];                         
    XmlResults rs = container.getAllDocuments(new XmlDocumentConfig());               
    while(rs.hasNext()){
         XmlDocument xmlDoc = rs.next().asDocument();
         XmlInputStream inputStream = xmlDoc.getContentAsXmlInputStream();                    
         long read=0;
         while(true){
         read = inputStream.readBytes(buff, BLOCK_SIZE);
    fos.write(buff,0,(int)read);                    
         if(read < BLOCK_SIZE) break;
    inputStream.delete();
    xmlDoc.delete();
    rs.delete();
    //MUST CLOSE!
    fos.close();               
    catch(Exception e){
    System.err.println("Error exporting file from container " + container);
    System.err.println(" Message: " + e.getMessage());
    Thanks.

  • Sort by Creation Date and TIME!

    I need to sort hundreds of images taken by three photographers and on six different cameras. I sort by Image Date, but it keeps each photographers images together, seems to sort by DATE only, then by file name.
    I have used iView Media Pro to sort this way and it is a GREAT way to organize this type of work. Is there a way to refine how Aperture 1.5.1 does this type of sort?
    At this point, my option appears to be to export my final picks, then resort and rename them in iView Media Pro.

    In the browser section, I clicked on the list view (control-L is the shortcut) and then clicked on the "Image Date" header, and saw all my images sorted by date AND time. Is this what you're looking for? If all the photographers shot on the same date and time, then they'd be intermingled I suppose, but if the times were separated, this should work. Give it a shot anyway.
    Mark

  • Is there a way to sort pdf by date created rather than by date added?

    In iBooks in Mavericks, is there a way to sort pdf by date created rather than by date added?

    I noticed that the "Year" information and "Release Date" information are usually wrong.
    For example, the song "The Twist" by Chubby Checker has 2007 for the year and 3/5/2007 as the release date. I understand that this is the release date of the greatest hits compilation album, but not the song.
    Is there any way to change the dates so that I can sort by year? I would like 60s songs to appear with a 1960s year or release date.

  • HT2905 Most all of my 1700 songs have been duplicated in iTunes. I have downloaded the instructions how to delete the duplicates but it says "sort by the date you added" and i have no column that says that. I am running windows xp.

    Most all of my 1700 songs have been duplicated in iTunes. I have downloaded the instructions how to delete the duplicates but it says "sort by the date you added" and i have no column that says that. I am running windows xp.

    Apple's official advice is here... HT2905 - How to find and remove duplicate items in your iTunes library. It is a manual process and the article fails to explain some of the potential pitfalls.
    Use Shift > View > Show Exact Duplicate Items to display duplicates as this is normally a more useful selection. You need to manually select all but one of each group to remove. Sorting the list by Date Added may make it easier to select the appropriate tracks, however this works best when performed immediately after the dupes have been created.  If you have multiple entries in iTunes connected to the same file on the hard drive then don't send to the recycle bin.
    Use my DeDuper script if you're not sure, don't want to do it by hand, or want to preserve ratings, play counts and playlist membership. See this thread for background and please take note of the warning to backup your library before deduping.
    (If you don't see the menu bar press ALT to show it temporarily or CTRL+B to keep it displayed)
    tt2

  • How can I sort pictures by date and than by time stamp ?

    The approx. 2.000 pictures was taken by two cameras.
    Both cameras intern date and time where adjusted before the for session.
    It seems that Aperture 3.3.1 can´t manage it, can it?
    In the browser there is only one common field for date and time.
    I shoot the picture with two Canon 5D Mark II and Mark-III in JPG and RAW mode.
    The file name only is totally confusing for sorting.
    Like IMG_0008, _MG_0022 for Mark-II
    and
    _L2A8410 for Mark-III.

    Hi,
    I am not sure, which sort order you want to achieve? If you sort by the date field, the images will be sorted chronologically, ascending or descending, according to date and time - isn't what what you want?
    Can it be that you have a time zone problem? Compare the dates on the images that should be sorted side by side.
    Unless you specify "Camera Time" and "Actual Time" on import, Aperture will assume that the camera time has been your current system time.
    Canon 5D Mark II and Mark-III
    And unfortunately, both your cameras are exactly the two cameras that I know, where the time zone correction in Aperture is buggy and does not have much effect. I cannot find the discussion again right now, but look for a thread by Frank Caggiano on time zone correction.
    Regards
    Léonie

  • How can i sort photos by date taken, not date created?

    How can i sort photos by date taken, not date created?

    I'd like this feature as well. I tend to browse my photos by date in Aperture, but on ios thay always appear in some bizzare random order.
    I've tried several workarounds but with no luck. As metadata is present, surely this should be simple...

Maybe you are looking for

  • JDBC Sender and Receiver

    Hello: I have an scenario FILE-to-FILE and it's working ok. So now I want to change it into FILE-to-JDBC so I thought just to change the Communication Channel RECEIVER, instead of file, use JDBC adapter. I've read this blog <a href="/people/sap.user7

  • What graphics card do I have in Satellite P850-138

    Hello, I bought my Satellite P850-138 from PC world and was told that it had a dedicated graphics card but when i run dxdiag, it says that my graphics card is Intel(R) HD Graphics 3000 can anyone offer any incite?

  • Payment Method- Wire transfer

    Hi, Payment menthod for country is not setup for wires, but it is there for check. Is this only through configuration, or something I can do?.. I am lookin for the solution apart from payment method configuration &  using F-53, Is there any other way

  • Why is my Macbook Pro unable to read Adobe Photoshop CS5 Extended cd?

    Everytime I load the cd, I hear the cd run, but nothing opens. I do not understand why this is happening. Please help

  • Deleting JAR Creation on JBuilder

    I used the Archive Wizard on JBuilder to create some archives that are created during building. But now I want to stop one from being created, how do I do it??? JBuilder doesn't seem to offer any way of keeping track of archives after you set one up.