Author |
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 22 December 2016 at 8:37am | IP Logged
|
|
|
Hi - is there a way to retrieve all the envelopes that have been "updated" since a certain date?
There's some good documentation on these two pages...
http://www.afterlogic.com/mailbee-net/docs/MailBee.ImapMail.Imap.DownloadEnvelopes_overload_3.html
http://www.afterlogic.com/mailbee-net/docs/MailBee.ImapMail.Imap.Search_overload_2.html
...however, I can't see how I can retrieve any messages which have changed in the last X period of time.
For example, I download all the emails and store them locally, but then I need 'sync' with the server in case any of the downloaded emails have been marked as READ, replied to, or even deleted.
I'm trying to work out how to ask the server to "get me any emails that have changed in the last 30 minutes" for example.
Many thanks for your help!
Kind Regards,
Hedley
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 23 December 2016 at 2:03am | IP Logged
|
|
|
Hi,
That's what you need to do:
- Search for UIDS passing SINCE yourdate, you get UidCollection (uids)
- then DownloadEnvelopes for the uids.ToString() and request EnvelopeParts .Flags. Uid is always requested automatically.
- So you got envelopes with Uid and Flags properties set
Now you can compare the with your local db, for each Uid, check its flags it remove and cached copy (this gives you difference in read/answered/etc).
If some uids are not present in cached copy, they are new. You create UidCollection (newUids) and add such uid there. In the end, you'll pass newUids.ToString() to DownloadEnvelopes passing EnvelopeParts.All to download such emails completely, with all flags)
If some uids are present in cached copy but not on remote, you'll need to remove these entries from your local db.
Entries which are present in both cached copy and remote copy but have different flags need to be updated so that cached copy would reflect the remote server state.
That's it!
Regards,
Alex
|
Back to Top |
|
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 23 December 2016 at 2:23am | IP Logged
|
|
|
Hi Alex - so just to clarify, the "SINCE" operator returns emails which have been modified since a certain point in time?
Your documentation says :-
SINCE <date>
Messages whose internal date (disregarding time and timezone) is within or later than the specified date.
So the "internal date" gets updated whenever anything changes on the email on the IMAP server?
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 23 December 2016 at 2:36am | IP Logged
|
|
|
Oh, I got your point. In your case if you need to process messages even if they are old but their flags changed recently. Then you just get UIDs of all messages on the first step, no SINCE. There is no way to determine which messages changed flags since certain date. IMAP does not allow that.
Messages don't have their internal date (or any other standard header or property) when their flags get updated.
Regards,
Alex
|
Back to Top |
|
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 23 December 2016 at 2:37am | IP Logged
|
|
|
...and just one further question (sorry!).
What about DELETED emails? I notice there is a "DELETED" flag, but are emails ever completely deleted off the IMAP server?
If they are, then presumably we need to do some further checking to see if some UIDS no longer exist on the server, and hence delete them locally - is that correct?
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 23 December 2016 at 2:42am | IP Logged
|
|
|
In IMAP, Deleted is just a flag. Emails with Deleted flag get removed when Expunge method is called. In your client, you can hide them from the user (or strike-though, like Outlook does) but this depend on your business logic.
Technically, they are normal messages, the only difference is that they get removed by Expunge.
Regards,
Alex
|
Back to Top |
|
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 23 December 2016 at 2:49am | IP Logged
|
|
|
OK - so if the user hasn't used the email client for a few days, it's possible that some messages held locally in the DB have been "expunged" and now no longer exist on the IMAP server?
Hence we should periodically get ALL UIDs from the server, compare them to ALL UIDs in the DB and then delete any DB records which no longer exist on the server?
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 23 December 2016 at 2:55am | IP Logged
|
|
|
Exactly.
Regards,
Alex
|
Back to Top |
|
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 23 December 2016 at 2:57am | IP Logged
|
|
|
OK - thanks for your help Alex - much appreciated!
|
Back to Top |
|
|