1
votes

I'm developing an application where a local Core Data database is kept in sync with the user's IMAP email account. I'm using MailCore (http://libmailcore.com) to handle all the IMAP API calls, but there seems to be some shortcomings. Here is what I want my app to be able to do:

  • Have a local copy of the most recent 50 emails on the server
  • Download all new emails the user has received since the last fetch, keeping a maximum of 50 still on the device.
  • Delete local emails that have been deleted on the server.

The only methods MailCore supplies for retrieving email are the following:

- (NSArray *)messagesFromSequenceNumber:(NSUInteger)startNum to:(NSUInteger)endNum withFetchAttributes:(CTFetchAttributes)attrs

- (NSArray *)messagesFromUID:(NSUInteger)startUID to:(NSUInteger)endUID withFetchAttributes:(CTFetchAttributes)attrs

Right now, I'm retrieving the latest emails from the server and downloading all the information about them, and then I retrieve the latest 50 UIDs from the server and compare them against my local cache to see what has been deleted. This seems very inefficient. Is there a better way to sync inboxes without two round trips to the server (at minimum)?

1
We are also working with mailcore and due to its poor documentation we couldn't find out even simple tasks like getting all headers of the email. May you help us - Sumit

1 Answers

0
votes

check for imap servers capabilities. Implementation of NOOP and imap idle capability is the answers to your query.