Search code examples
exchange-serveractivesync

EAS Protocol fetch unread mails only


I am implementing the ActiveSync protocol and currently i am able to fetch emails using Sync command. Right now everytime i execute the sync commands it provides me all mails what i am assuming if i am using same sync key it must returns new mails arrived since my last sync request. Below is my request.

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<airsync:Sync xmlns:airsync=\"AirSync\">
   <airsync:Collections>
     <airsync:Collection>
        <airsync:SyncKey> 321039710239710
        </airsync:SyncKey>
        <airsync:CollectionId> 7
        </airsync:CollectionId>
     </airsync:Collection>
   </airsync:Collections>
</airsync:Sync>


Solution

  • Actually, when you call Sync, you get a new Sync key. So the next Sync should use the Sync key returned by the previous Sync. If you re-use the same Sync key over again, you should get the same messages back every time.