How to sync deleted emails with the Desktop clients
I am planing to work on an application which retrieves Yahoo account emails by using "Yahoo! Mail Web API".
1) Initially getting all emails message ID's by using "List of messages" 2) Processing each and every message from the message ID list and saving all message information to the local desk. 3) During the next sync downloading only newly received emails from the last sync.
The above logic works fine to keep in sync with the server for newly received emails but not works for deleted emails.
Lets say client has completely finished first sync with the server and after that some emails are deleted from the yahoo server. Now client will have all those deleted email entries, So how to keep in sync for deleted emails in this case.
I have gone through the documentation regarding it and not found any documentation to address this issue.
Only way I can find is getting all message ID's from the Yahoo server and syncing with the local message ID's copy. But pulling all message ID's every time just for syncing deleted emails is too expensive.
I think it is good to provide only deleted message ID's from the client Last sync.
Could you please suggest Is there any other way to solve this problem?
- In the first iteration, use ListMessages() to download and store all message IDs and the receivedDate values.
- In subsequent iterations, use ListMessages() to download the same information. Compare the message IDs you get in this iteration to the ones you've seen in the previous iteration. Message IDs you stored in the previous iteration that are not present in the current list have been deleted from the server. Message IDs that are present in the current list but not in the previous iteration are new messages. You can use the message dates to restrict the message ID fetch and comparison only to a valid date range.
Unfortunately, this doesn't work.
This is because message IDs for a given message can change over time! As of now, I haven't figured out a way to do this short of downloading the entire message header (GetMessage()...) for all messages at each iteration and comparing the To/From/CC/Bcc/Size... fields to identify messages currently on the server with the messages I received in the previous iteration (in my message store). Obviously, this is unacceptable for production use since this can take way too long and really beats the purpose of doing an "incremental" check.
Anyone have a suggestion on how to uniquely identify a message that doesn't change over time? Message IDs don't seem to support this requirement.