Read all Emails Against Search Query For Office365 Outlook

82658846 1 Reputation point
2021-04-07T14:45:29.123+00:00

I want to read all emails within my tenant against a query using Office365 Outlook API. Currently, I am enumerating one user at a time and extracting all the emails for it

https://graph.microsoft.com/v1.0/{userId}/messages?$search="from:abc[@](/users/na/?userId=9628448e-7ffe-0006-0000-000000000000).com"

This approach is not scalable as in the case of 1000+ users it will take a lot of time. I want to extract the emails for all users against a query but without enumerating individual users.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,716 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Brian T. Jackett 1 Reputation point Microsoft Employee
    2021-05-03T18:42:09.2+00:00

    Agreed that that approach isn't as scalable. Have you explored Microsoft Graph data connect? For extracting emails (or other supported data sets) at scale that would be a recommended starting point. If that doesn't meet your needs we'd love to hear your feedback.

    Overview of Microsoft Graph data connect - Get access to data at scale
    https://learn.microsoft.com/en-us/graph/data-connect-concept-overview#get-access-to-data-at-scale

    Get started with Microsoft Graph data connect
    https://learn.microsoft.com/en-us/graph/data-connect-get-started?view=graph-rest-1.0

    0 comments No comments

  2. Anonymous
    2021-05-03T19:32:13.163+00:00

    Adding to @Brian T. Jackett comment. Microsoft Graph data connect (MGdc) would also remove the throttling factor and allow you to extract emails in Bulk very quickly. With MGdc you can either extract entities from all users in your tenant or select specific groups. You can also filter out fields for privacy concerns, so if for example you want to extract information about all emails sent but not retrieve the body of those emails, you can.

    0 comments No comments