Problem deleting e-mail
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   paolo_rossetto
Posted On:   Tuesday, October 7, 2003 05:48 AM

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. 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 message   More>>

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.

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

   <<Less

Re: Problem deleting e-mail

Posted By:   Christopher_Koenigsberg  
Posted On:   Tuesday, October 7, 2003 06:11 AM

In the Pop servers I have encountered, as a client you only work with a temp copy of the inbox. You don't see any newly arrived messages, unless you explicitly check for them, which refreshes your temp copy of the inbox.

About | Sitemap | Contact