Search mail with Graph API using filter Email and Subject

ASM Automation 20 Reputation points

Hi All,

I am trying to search a mailbox by passing email ID and subject but unable to get the proper URL, can somebody please help here with the proper URL

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,150 questions
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 39,101 Reputation points

    Hi @ASM Automation

    Yes, you can filter messages by date, subject and sender.

    Example:$filter=subject eq '{subject}' and sender/emailAddress/address eq '{sender email address}' and sentDateTime ge 2023-05-17T07:28:08Z

    User's image

    Hope this helps.

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

1 additional answer

Sort by: Most helpful
  1. Glen Scales 4,431 Reputation points

    I am trying to search a mailbox by passing email ID and subject

    Depends which Email Id are you trying to search with ? the only Id that would be searchable is the internetmessageId if you have the GraphId/itemid you don't need to search just try a get using the identifier.

    To search using the internetmessageId you can use$filter=internetMessageId eq '<>'

    There's actually 3 different ways of searching for messages a Filter, Search and the Graph Search endpoint so for Subject you can use either a KQL query$search="subject:\"Fwd: Subject string to search\""

    or and exact filter match$filter=subject eq 'Subject to search'

    or startswith$filter=startsWith(subject,'test')

    or you can also use the search API

    1 person found this answer helpful.