Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best strategy to avoid to download all readed emails
#2
(01-05-2022, 04:49 PM)luigisic Wrote: But, because the emails are over 3.000 (that increases about of 100 emails per month) this code:
    IMAP.SelectMailBox('INBOX');
runs for about three minutes and more.

That would make sense if you have the TIdIMAP4.RetrieveOnSelect property set to something other than rsDisabled, which would cause SelectMailBox() to download all headers/bodies in the selected mailbox.

(01-05-2022, 04:49 PM)luigisic Wrote: What is the best strategy to avoid to lost about 3 minutes every time i do: IMAP.SelectMailBox('INBOX');

Make sure RetrieveOnSelect is set to rsDisabled, so you can decide what you want to download and when. You can then use (UID)SearchMailBox() to search for just skUnseen/skNew messages and retrieve their IDs, then you can download the headers/bodies for just those IDs as needed.

Technically, a better solution is to use the IMAP IDLE command to let the IMAP server notify you in real-time whenever new emails arrive, instead of you having to poll for them periodically. However, TIdIMAP4 does not support that command yet (it is on the TODO list), but you could try implementing it yourself, if you want.

Reply


Messages In This Thread
RE: Best strategy to avoid to download all readed emails - by rlebeau - 01-05-2022, 07:01 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)