How can i get emails From and To a specific user or an email address in microsoft graph api ?

Varun 20 Reputation points
2024-10-22T23:01:34.64+00:00

I am working with a mailbox that requires emails that are sent to or received from a specific email adsress.

I tried using the following url for the api call:

"url": f"me/messages?$filter=(from/emailAddress/address eq '******@domain.com' or toRecipients/any(t:t/emailAddress/address eq '******@domain.com'"

But got the following error :

{
  "detail": "Error fetching messages by contact: 'value'"
}

How can I modify the filter to resolve this issue?

Outlook | Windows | Classic Outlook for Windows | For business
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2024-10-23T02:17:16.2733333+00:00

    Hello Varun,

    Thank you for reaching out to Microsoft Support!

    Please try using the $search parameter, the url is below, please see the documentation for details:

    https://graph.microsoft.com/v1.0/me/messages?$search="from:******@domain.com" or "recipients:******@domain.com"
    

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.