Author |
|
NobodyFamous Newbie
Joined: 19 October 2007 Location: Canada
Online Status: Offline Posts: 11
|
Posted: 19 October 2007 at 3:42pm | IP Logged
|
|
|
Hi,
I REALLY need to be able to force messages marked for deletion to actually be deleted without using .Disconnect(). Is there anyway I can do this?
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 21 October 2007 at 4:54am | IP Logged
|
|
|
Only with IMAP. POP3 does not support this and this is fundamental limitation (because POP3 session state model is based on assumption that the number of messages never changes during the session).
Regards,
Alex
|
Back to Top |
|
|
NobodyFamous Newbie
Joined: 19 October 2007 Location: Canada
Online Status: Offline Posts: 11
|
Posted: 22 October 2007 at 12:17pm | IP Logged
|
|
|
I'm assuming you mean POP3 session state model is referring to your internal component state model. Chilkat .NET's POP3 component has this ability (however it's way too slow at downloading email).
This is really a show stopper for me :( No ideas at all?
|
Back to Top |
|
|
NobodyFamous Newbie
Joined: 19 October 2007 Location: Canada
Online Status: Offline Posts: 11
|
Posted: 22 October 2007 at 12:24pm | IP Logged
|
|
|
I should elaborate.
My problem is this:
POP3 Inbox has 1500 messages let's say. I start downloading them. I Download in a way that I grab one at a time, process and store it locally in a database, and then delete it from the server. Then I move onto the next message.
The problem is, if for some unforeseen circumstance, the application throws an exception that is unhandled, the Disconnect() method may not be thrown. If this happens, when the application is restarted, it starts downloading all of the messages over again, even the ones it downloaded and stored before the exception was thrown.
I've already thought about putting a big try catch block around the code and then having a .Disconnect() in a finally block, but this is poor coding, and would require putting many many lines of code in the try catch block to accomplish this. Not nearly ideal.
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 22 October 2007 at 12:49pm | IP Logged
|
|
|
Quote:
I'm assuming you mean POP3 session state model is referring to your internal component state model. |
|
|
I'm referring to POP3 session in general, not in regard to MailBee.
Quote:
Chilkat .NET's POP3 component has this ability (however it's way too slow at downloading email).
|
|
|
It's not an ability. It's simply an internal call of disconnect and the following connect. You can do the same with MailBee but it will be slow too due to overhead of making connection and logging into a mailbox each time you delete a message. Also, expunging messages one by one is slow (especially if the mail server manages the mailbox as a single file and expunging message #1 requires rewriting the entire mailbox file to adjust the contents).
The elegant solution is keeping UID list and downloading emails accordingly this list. When you connect to the mailbox, you get the list of UIDs (Pop3.GetMessageUids). If you save it somewhere, you will then know which messages you have processed. For instance, each time you download a message, you change the corresponding UID value with empty string and proceed.
Next time, you will not have to download everything - you just refer to your UID list and start from non-empty value.
Pop3.GetMessageIndexFromUid method is also here to help you download message by its UID value. This is because next time you log in the mailbox, message indices may change while UID values will be left intact. So, it's more reliable to refer a message by its UID rather than by its ordinal message number.
You even do not actually need to delete messages at all in this case because you will now use UID-based approach to detect if the message had already been downloaded (although you can delete them if required). Outlook and other email clients do the same. This is standard practice of downloading POP3 mail.
Regards,
Alex
|
Back to Top |
|
|
NobodyFamous Newbie
Joined: 19 October 2007 Location: Canada
Online Status: Offline Posts: 11
|
Posted: 23 October 2007 at 6:46am | IP Logged
|
|
|
Ok, after reading the RFC i understand now. I was under the impression DELE should actually purge the mail from the server. This is probably why Chilkat's component was responding so slowly, since I was calling a delete after every email which would have called QUIT to get the transaction into the UPDATE status.
I'll have to change my approach a bit. Thanks.
|
Back to Top |
|
|