Forum Discussion

thinktoday's avatar
thinktoday
Copper Contributor
Oct 13, 2020

Efficient way to fetch all emails from Outlook Mailbox

Hii, I have a use-case where I need to fetch all mails form mailbox...

 

Now I have been using graph API(/messages), cannot use delta sync because it will work only for folder level sync. According to my use-case, I should fetch emails by time not by folder... So, I have used /messages to fetch like this...

First Sync:

 

https://graph.microsoft.com/v1.0/users/UserId/messages?$filter=receivedDateTime lt firstSyncTime&$orderby=receivedDateTime&$top=125

 

Second Sync:

 

https://graph.microsoft.com/v1.0/users/UserId/messages?$filter=receivedDateTime gt firstSyncTime&$orderby=receivedDateTime&$top=125

 

Third Sync:

 

https://graph.microsoft.com/v1.0/users/UserId/messages?$filter=receivedDateTime gt secondSyncTime&$orderby=receivedDateTime&$top=125

 

 

It works fine for mailboxes with a small number of emails... If the size gets bigger the mailbox gets throttling, I agree that is the behavior we can fetch again after waiting some time... But for some mailbox even after the first call, I throw errors like Service Unavailable...

 

Any reason for this issue?

Or Can I know Is this efficient way to fetch emails from the mailbox even for a large number of mails... If not please suggest any other possible ways to achieve this use-case...

 

No RepliesBe the first to reply

Resources