0

As per documentation we have two ways to fetch mails using Graph api.

  1. Using $filter with .top(int ) we can fetch list of messages.
  2. Using message id we can fetch a single mail.

I have 50000 mails in my folder. I am using pageSize=500.Its working fine. Now I also want to move/delete/change status of a mail based on some criteria.

After performing update operation(move/delete/change status) my next page is getting disturbed. Its skipping few mail because in next page top is used.

For example : I have 25 mails in folder, I am using $filter with page size=3, top(3) so that only 15 mails are eligible for filtration. Now in each page I am getting 3 mails.

Now when I apply any update operation , after that I am not getting expected mails in next page. Some mails are getting skipped.

Any idea how we can over come this?

MY APPROACH: Fetch all message ids and keeping it in my cache. From next time onwards, I am using these message ids and fetching mails one by one.

Now the issue is that fetching 500 mails one by one is hitting performance badly. Do we have any api where we can send list of message ids and get List of messages?

Or

Do we have any settings such that next page fetching query will start from exactly next item.

Rob
  • 14,746
  • 28
  • 47
  • 65
Afsar
  • 89
  • 7

1 Answers1

0

Might be better to scan your list first (cache up your updates), and then batch the updates together after you've iterated the list. Aside from fixing your problem, probably more efficient as well.

Barry Gervin

Barry Gervin
  • 63
  • 1
  • 6
  • Thanks @Barry for your suggestion. We also have this as an option but its not giving like real-time feel. If we are in a loop and performing some update then its expected to reflect at server side. We have other option to handle this by updating our query with since datetime. Let's see – Afsar Feb 14 '23 at 08:39