Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
680 views
in Technique[技术] by (71.8m points)

How to find total count of emails (Read/Unread) within a specific date range using Microsoft Graph Mail API?

I have a scenario where I want to find out the total number of emails within a specific date range. I am currently using the List Messages API (GET /users/{id | userPrincipalName}/messages) and tried specifying the $count=true parameter but it is not returning the correct value. I researched on this and found out that the @odata.count value for messages is not reliable and has a bug where it fails to report the correct count (Very Strange).

Another option is to explore the List Mail Folders API (GET /users/{id | userPrincipalName}/mailFolders) which has a totalItemCount value that I can use but unfortunately there is no way to specify a date range in this API.

Finally, the most crude option is to use the List Messages API and manually count the number of items returned but obviously it will not be efficient.

Can someone please let me know how this can be achieved in a better way?

Edit: The $count=true gives correct value when I get emails inside a specific folder (/users/{id | userPrincipalName}/mailFolders/{id}/messages) and not all emails for a user (/users/{id | userPrincipalName}/messages). Is there something I am missing?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...