Problem deleting e-mail (folder return newest messages first, older last)

I made a program, using javamail, to accomplish a quite sofisticated mail forward.
I read a specific mailbox, I read each message in the INBOX, and in some conditions (I read the content, get a predefined field containing a product ID, read a database and check if the price is high) I forward the e-mail.
Then I delete the forwarded email from the inbox.<br>
I am using pop3 & smtp, and I have First Class from Centrinity as Mail Server.
The problem I have is the following:
1) in the messages array filled with Message[] messages = folder.getMessages() I get the newest messages first, the older last.
2) I scan the array, and, based on the Item price (as explained before) I delete some messages: messages(i).setFlag(Flags.Flag.DELETED,true)
3) messages are phisically deleted only when the folder INBOX is closed: folder.close(true)
4) if new messages arrives before closing the INBOX, THE WRONG MESSAGES ARE DELETED!.
Example:
- I have 3 messages in the inbox;
- the program start;
- I process the message number 1, I forward it, I delete it;
- I process the message number 2, no forward, no delete;
- (a new message "NEW" arrive now);
- I process the message number 3, no forward, no delete;
- I close the folder
- THE NEW MESSAGE IS DELETED!!!!!!
I am sure this is because of the ordering of the messages, but I cannot figure out a safe deletion while new messages arrives (and I cannot think I can't solve this problem: no pop3 client should exists!!)
Thanks in advance for the help
Paolo Rossetto

Please take a look at : http://java.sun.com/developer/onlineTraining/JavaMail/contents.html
and you will find the answer

Similar Messages

  • I have mistakenly deleted a mail folder which I had created. Can't remember if it was located to 'iCloud' or 'On My Mac'. How can I retrieve the emails contained in this deleted folder? Your help will be immensely appreciated!

    I have mistakenly deleted a mail folder in which I had created. I can't remember if it was located to 'iCloud' or 'On My Mac'. How can I retrieve the emails contained in this deleted folder? Your help will be immensely appreciated!

    Yeah not a problem. It does seem though that if you did not have a Time Machine backup then you may not be able to recover the deleted folder :/ But for future reference to prevent any of this, a Time Machine backup is a great investment.
    What it does is create an entire backup of your computer anything from personal information down to the screen saver.
    What you first need is a new external hard drive (I would recommend a 1TB or higher just to prevent running out of space soon).
    after that, just plug in the drive to your computer.
    once it is plugged in, in the top right hand corner, close to the wi-fi symbol, you should see a symbol that looks like a clock with a backwards arrow around it.
    click on that and select "open time machine preferences"
    just turn the button to the "on" position, and select the backup drive and Time Machine does the rest
    very great tool

  • Something wrong with my email it keep eat up my hard drive.  how can i get into the system and delete the mail folder

    how can I delete the mail folder in the hard drive.. it keep redownload the emails and eat up my hard drive

    If you have your mail set up as an IMAP account, then it will download everything that is in your Inbox (on the online site/server) again and again. You can move your emails to another folder online after you've read them or you can also delete them online after you've saved the ones you want to keep.
    If you have your mail set up as a POP account, emails are downloaded once and then reside on your hard drive; you can indicate in Mail Preferences > Accounts if you want the messages online deleted immediately or after one week, etc.

  • Deleting e-mail boxes in the messaging folder

    Hi, i hope someone can help, is it possible to remove e-mail boxes thet i have created in the messaging folder of my n81 8gb.
    While setting up my e-mail i somehow managed to open 3 mail boxes in the messaging folder, the one i ment, "aol" plus two others "aol01" and "aol02", they don't have a delete button in the options menu.
    giantrust.

    Go to MESSAGING, press OPTIONS, SETTINGS then EMAIL. Once there, MAILBOXES. Now you should be able to list all your accounts. Select the one you want, press OPTIONS, delete.
    Información sobre Symbian / NSERIES en Español en http://symbianespanol.wordpress.com

  • HT2500 How do you delete bulk mail folder in Mail program?

    In my Mail program on my MacBook Air there is a Bulk Mail Folder usually full of annoying junk mail. How do I eliminate this folder so I don't get Bulk mail anymore?

    Hi Macmonter,
    i have seen the complete post here and realised that your answer should have been selected as most useful, unfortunately Charlie7 didn't tried it and hence it was ignored. I still appreciate your experiemnt.
    I am pretty new to this community thing, but i did a lot of experiments with Mail application and hence i m writing this post specifically which might be helpful to others. I use Yahoo Mail (only) for all online services like Facebook, G+, LinkedIn, Twitter etc. all possible. It's my central ID now and i cant change it any more. Going online and checking yahoo mail is sometimes very resource taking hence i decided to use mail client like Mail.app. Let me tell you that i personally tried all other mail apps including thunderbird but noticed one very imp thing that when u use Mail.app then your mails 7 their attachments are automatically indexed by Mac OS which is very important feature and when you search something then it searches within your mail also, this is really awesome. This will not happen if u use thunderbird or any other mail client. Also you get to use free Cloud with auto sync. Now this also tells you that I am stuck with 2 (idiotic) giants : Yahoo & Mac OSX Mail.
    The thing is, Yahoo now uses IMAP (prior it was POP). IMAP has many advantages over POP for sure. Basically when you use multiple devices, filters and folders and want all those things in Sync. Google for more comparison, but let me tell you IMAP is really good. Now the problem is, Yahoo has powerful spam engine but it calls it 'Bulk Mail'. Apple also has powerful Spam Engine but they call it 'Junk'. So some how you have make apple understand that they are the same words, which is suggested by Mr. Macmonter which is really a great & very useful thing. If you mark 'Bulk Mail' folder as 'Use As Junk' then you are done. All messages from Bulk folder will be routed to Junk and you will see common Junk Folder.
    I know there are people who dont want to see that Junk at all! And for that this is smart trick :
    Configure your Yahoo as IMAP (which is default). Clear all messages from online Bulk Mail folder using browser login. Then Sync so all your online folders are downloaded if any and all your mails. Basically this is for people who has created online filters and folders (i have 12 folders)
    Once your account is in Sync, disconnect. Export all your folders one by one slowly. It takes times if you have many mails and attachments. Once this is done successfully, DELETE this account!
    Now create Yahoo POP account. Apple dont allow you to do this now, but there is trick. You will have to give wrong user-pass and shift to manual settings and there you can give correct server config which should be POP settings of Yahoo. And take this account online.
    In online Yahoo Mail, set 'Do not download spam' under POP and Forwarders. So this will only start downloading Inbox messages. Remember POP dont see any other folders, hence we removed all filters and downloaded all folders. IT will download all mails coming to Inbox filtering Spam. So you never see spam. If you want to see some then you can go online periodically and check manually.
    Now import your recently exported folders in this account and create filters and rules in Mail.app for routing of incoming messages for particular messages.
    This gives you all old messages, pure inbox from yahoo, 2 way spam filter yahoo & Mac, and local routing of messages with index, smart folders and cloud! Only thing you dont get here is Sync with multiple devices if you have iMac, Air & iPhone. But there i suggest you to keep one of them as center for downloads and others should keep just 15days old copy. This will also save your resources!
    Enjoy..

  • Problem with "sent" mail folder-how do I trash the prefs in Apple Mail?

    Since no one has answered my original request for assistance regarding my "Sent Mail" mailbox, I'll move the issue aside and approach it differently: How do I trash the prefs in Apple Mail without trashing my inbox and all the other mailboxes? Trashing the prefs works for most apps, but if I do that to Mail, I'm screwed. My real problem remains: I can no longer see or read the email in my "sent mail" box; I can see the info identifying the entry, but I can't read the contents of the email. It's all there in the Mail folder on my hard drive, but it doesn't show up in the Mail app.
    So how can I trash the prefs for "Mail" without trashing my inbox?

    Hello b:
    I have only had to trash the Mail preference once, and I cannot remember what occurred (except that the application worked OK after that).
    Before you trash the preference file, try rebuilding the mailbox(s).
    Barry

  • Deleting bulk mail folder

    How do I delete the bulk mail folder in my yahoo email on my iPad2?

    From what I see you can't delete the bulk folder.
    However if you sign in to your web mail and look at settings you can select that the spam mail not be sent.
    I haven't checked another thing out but it may work.
    When I signed up my emails with a new imac, I noted that it created an imap program rather than a pop3.
    Maybe deleting your accounts and then setting them up as a pop3 and smtp, you might avoid these bulk folders.

  • How to get and delete questionable mail without actually opening it first.

    I am new to Apple again, having bought my first Apple many years ago (an Apple 2C). Does anyone know if I can get mail and delete it without opening it first? If so, I am thinking it is somehow in Preferences but I cannot figure it out. I often get mail from unknown sources (left over from my PC days - ?able viruses on PC) that I don't wish to take the chance to open. In order to delete it, I have to open it first. Any thoughts?? Thanks in advance for your help.

    Actually, there is a risk in viewing certain messages, but only if you have enabled Preferences > Viewing > Display remote images in HTML messages — see How HTML Email Messages Relate to Unsolicited Commercial Email ("spam").
    As long as Display remote images in HTML messages is OFF and you don’t click on any hyperlink or image the message may contain, you can safely view any messages you receive in Mail.
    That said, there are at least three ways to select a message and delete it without displaying its contents:
    (1) You can hide the preview pane by dragging the separator bar between the message list and the preview pane to the bottom of the window, or by just double-clicking within the separator bar, so that the preview pane disappears and only the message list is visible. To make the preview pane visible again, drag the separator bar up from the bottom of the window, or just double-click on the separator bar again.
    (2) If you select the message with the mouse, the message is displayed in the preview pane when the mouse button is released, not when it’s pressed. This allows you to drag the message to the Trash or to any other mailbox without Mail trying to display its contents.
    (3) Ctrl-clicking on a message causes a contextual menu to appear, from which you can usually (but not always, don’t ask me why) choose Delete or Move To, before the contents of the message are displayed in the preview pane.

  • Deleting email mail box in the messaging folder 61...

    does anyone know how to delete extra email mail boxes that have been manually set up by me in menu - messaging -
    the screen has new message
    inbox
    my folder
    email
    gmail
    Gmail
    the last 3 i have set up and I don't want/need them there - there is no harm having them Id just rather neaten it up -
    any thoughts?
    TIA
    steph

    Go to MESSAGING, press OPTIONS, SETTINGS then EMAIL. Once there, MAILBOXES. Now you should be able to list all your accounts. Select the one you want, press OPTIONS, delete.
    Información sobre Symbian / NSERIES en Español en http://symbianespanol.wordpress.com

  • Problems deleting in Mail

    Any thoughts on how I solve this annoying problem? When I click on a single Mail item to delete it sometimes more than one item is deleted. This is not consistent...often it is fine, other times it deletes two or even three or four items in rapid succession which I then have to retrieve from trash (I have to notice it has happened in the first place which is what's worrying me). Problem doesn't seem to be result of different pressure on the keys or any other logical reason, it's completely random. Been happening for two weeks.

    Hi Chris,
    Search for 'Deleted Messages.mbox' in a Finder window with 'system files included'.
    This will bring up a folder for each email account you hold plus an additional one.
    You will need to follow the paths for each folder. It's a bit tedious. The emails will be named '12345.emlx' and you should be able to get a preview of them without opening Mail. Just move them to trash.
    I regularly find emails that I deleted weeks and months ago. I thought they might be taken care of by the maintenance scripts, but they're not.
    Remember that you are tinkering around with system files here so be careful. Make sure Mail is closed, make sure you have a working back-up, and make sure you definitely don't need what you're deleting!

  • Problem deleting E-mails

    Does anyone know why it wont let me delete emails from my AOL account? When i try they will disappear and in a few seconds I get the pop up message that the email could not be moved to trash. Then the email reappears. Anyone know how to resolve this problem?

    jel1
    Welcome to the Discussions Boards.
    Search will work, but here are two threads that may help.
    http://discussions.apple.com/thread.jspa?messageID=8552368&#8552368
    http://discussions.apple.com/thread.jspa?messageID=8623575&#8623575
    Essentially, you can correct it by going to Settings > Mail, Contacts & Calendars > select your AOL account > Advanced > Deleted Mailbox > if the On My iPhone entry does not say Trash, change it to Trash. If it already says Trash, tap on the Trash entry one time. From then on you should be able to delete messages with your AOL account once again.
    Charles H.

  • Junk Mail - On My Mac - Problem Deleting Junk Mail

    In the Junk Mail box, there are two sub-folders under it. One says "On My Mac" the other says "Home". The main junk mailbox looks empty. The "On My Mac" mailbox looks emtpy too, but there is an icon next to the folder that says there are 95 messages in there. When I select the folder and go to "Erase Junk Mail" nothing happens. Still nothing is appearing in the main window, but the little icon still shows 95! That number keeps getting bigger too.
    How do I get rid of those once and for all. And I kinda want to see them to make sure they are really junk.
    Thanks

    Phil,
    I don't have time this morning, before having to go to two church services, to stay with you, but will later in the day.
    I need to know all the types of accounts you have. It appears you have at least one .mac account, and one IMAP account. The later is based on the report of the Junk (home).mbox in the Mailboxes folder. With a POP account, the Junk.mbox would properly be in the account folder, and not in the Mailboxes folder.
    Regardless of that, the Junk(.mac account).mbox should be at the first level of the Mailboxes folder, and not WITHIN a plain Junk folder. With this structure so mixed up, it is possible to have important messages that you have not seen.
    More info, please.
    Ernie

  • I am having trouble downloading the new outlook mail.It returns error message about a sync services agent, database daemon etc. Also, I Can send an email but it returns with message: "message could not be sent." Any suggestions for this Apple novice?

    I try and download the new Outlook update and it says I have to close sync services agent and others.I do that,or 'think' I do but it doesn't close.

    PS - have found other posts indicating that clips smaller than 2s or sometimes 5s, or "short files" can cause this. Modern style editing often uses short takes ! Good grief I cannot believe Apple. Well I deleted a half a dozen short sections and can export, but now of course the video is a ruined piiece of junk and I need to re-do the whole thing, the sound etc. which is basically taking as much time as the original. And each time I re-do it I risk again this lovely error -50 and again trying to figure out what thing bugs it via trial and error instead of a REASONABLE ERROR MESSAGE POINTING TO THE CLIP IT CAN'T PROCESS. What a mess. I HATE this iMovie application - full of BUGS BUGS BUGS which Apple will not fix obviously, since I had this product for a few years and see just hundreds of hits on Google about this error with disappointed users. Such junk I cannot believe I paid money for it and Apple does not support it with fixes !!!
    If anyone knows of a GOOD reasonably priced video editing program NOT from APPLE I am still looking for suggestions. I want to do more video in future, but obviously NOT with iMovie !!!

  • I am still having problems deleting e-mails that other people have sent in.  Help

    I obviously haven't ticked all the right boxes.  My original question has been answered, so for the time being until I have another question I would like these e-mails to stop.
    Help.

    See also:  Re: Where Do I Go to Access My Profile - E-Mails Are Killing Me?
    -Noel

  • Problems trying to SUM after returning date on first row in all rows

    Hi,
    I'm having problems with a calculation in a table report.
    We've built a Discoverer report that looks at long term absence of an employee. The long-term absence period must be worked out based on a 2-year rolling period from the start date of the employee's most recent sickness. For example, if i'm off sick and have been since 01-Mar-2009 the report will look at all absences i've had since 01-Mar-2007 and sum the days.
    I have built a calculation that always returns the latest absence start date for every row of absence a person has had. This has been achieved by using a LEAD Function and ROW_NUMBER, see below:
    LEAD(Absence Start Date,ROW_NUMBER() OVER(PARTITION BY Employee Number  ORDER BY  Absence Start Date DESC)-1) OVER(PARTITION BY Employee Number  ORDER BY  Absence Start Date DESC)
    The problem I have is that I cannot SUM the Absence Days of the person and bring in one row per person in the report. I think the cause is the use of the ROW_NUMBER. It ends up returning a Row for every absence the person has had.
    Is there any way I can achieve returning the latest absence start date of a person against all absence rows (in order to use a condition to restrict the report to all absences that started after 2 years prior to that date) that they've had and sum up the absence days so that only one row per person is returned? I cannot use row generators and cannot register PL/SQL functions. I would need to get IT to help me which is min 3 month turnaround, so I'm trying to resolve this quickly.
    Hope you can help.
    Many Thanks,
    Lloyd

    Hi Michael,
    Thanks a lot for this. The calculation you provided fixes the issue. However, The partition part of it seems to cause another.
    In order to calculate total absence days the following calculation is used:
    SUM(CASE WHEN NVL2("Absence (Employee) - Historic"."Date End",( CASE WHEN Absence Finish >= Absence Start THEN "Absence (Employee) - Historic".Absence Days END ),CASE WHEN "Absence (Employee) - Historic".Date Start < Period Start Date THEN WORKING_DAYS_BETWEEN(Period Start Date,Absence Finish) WHEN Absence Finish >= Absence Start THEN WORKING_DAYS_BETWEEN(Absence Start,Absence Finish) END) = 0 THEN DAYS_BETWEEN(Absence Start,Absence Finish) ELSE NVL2("Absence (Employee) - Historic"."Date End",( CASE WHEN Absence Finish >= Absence Start THEN "Absence (Employee) - Historic".Absence Days END ),CASE WHEN Absence Finish >= Absence Start THEN WORKING_DAYS_BETWEEN(Absence Start,Absence Finish) END) END) OVER(PARTITION BY "Person Assignment Information (Person) - Historic".Employee Number ORDER BY "Person Assignment Information (Person) - Historic".Employee Number )
    Here is a little Key:
    Absence Start
    GREATEST("Absence (Employee) - Historic".Date Start,ADD_MONTHS(TRUNC(SYSDATE),-24))
    Absence Finish
    LEAST(NVL("Absence (Employee) - Historic".Date End,TRUNC(SYSDATE)),TRUNC(SYSDATE))
    Period Start Date
    ADD_MONTHS(MAX("Absence (Employee) - Historic".Date Start) OVER(PARTITION BY "Absence (Employee) - Historic".Employee Number ORDER BY "Absence (Employee) - Historic".Date Start DESC ),-24)
    The item Absence Days is the number of days input against the absence by the user. This is only correct for end-dated absences. For people who have open-ended absence or those whose absence start before the period start date (Michael's date) we must work the days out. A function called WORKING_DAYS_BETWEEN achieves this. There is also another function called DAYS_BETWEEN which is all days between two days (weekends included).
    The item Date Start is the absence Start Date, Date End is the Absence End date.
    The whole lot is then summed by Employee number partition.
    The report has lots of indicators that using mathemical equations based ont Total Absence Days. In order to use Total Absence Days in another mathematical calc I have to create a duplicate calculation except without the partition (Total_Absence_Days in this case). If don't and simply insert the name of the calc into another calculation I get this error when running the report.
    Image: !http://www.aerographicsuk.com/Invalid%20Identifier.jpg!
    When creating another mathematical calc I then have to do the Sum partition around it. This makes the report run really slow because i'm typing lots of large formulae every time i build a calc that refers to Total Absence Days.
    Is there a way I can create the total absence days calculation with out causing this error? I have thought about breaking it up into several calculations but am wondering if i'll get the same error message.
    Below is an example of a calculation that tries to use Total Absence Days:
    GREATEST("Full Pay Entitlement (Days)"-SUM(Total_Absence_Days) OVER(PARTITION BY "Absence (Employee) - Historic".Employee Number ORDER BY "Absence (Employee) - Historic".Employee Number ),0)
    Kranthi, I can only paste in the Oracle SQL, which isn't real SQL. There are lots of other calcs though, so they'll probably be a lot there. Please let me know if you'd like to see it.
    Many Thanks for your help with this,
    Lloyd

Maybe you are looking for

  • Question about the ASA 5550 CSC module antivirus functionality with client VPN

    Here's a quote I got from SonicWall in regards to antivirus endpoint control. "EPC conducts robust pre-authentication interrogation of remote endpoint devices to identify the device, as well as determining the integrity of the device leveraging end-p

  • How do I get my Itunes on my laptop to sync with my new Ipad?

    I just got a new ipad mini and I want be able to use my itunes that I have on my laptop on it - help please - im not good with technology :/

  • Printing report at top of the page.

    Hi I have a problem in printing my report.I am using report 3.0 version.When i am printing my report.I want to print to print at position (0,0) i.e means I want to print almost top of the page.For me what's happeing is it leaving quarter inch top of

  • Event handler method

    Hi all, I want to know the significance of creating event handler method in Class builder. and how it can be used at the time of event trigger.( Is it called automatically or programmer need to call it explicitly in the program.) Thanks, Sushant sing

  • Jdeveloper 9i - Debugger Question

    Some more info: 1> I start java in debug mode set PATH=d:\jdev9i\jdk\jre\bin;%PATH% cd d:\jdev9i\j2ee\home java -ojvm -XXdebug,detached,port4000 -jar oc4j.jar 2> You'll see the following message: *** Port is 4000 *** *** Connect debugger anytime for