Search mail with Graph API using filter Email and Subject

ASM Automation 0 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 Explorer API
Microsoft Graph Mail API
Microsoft Graph Mail API
A Microsoft API that supports accessing data in users' primary mailboxes and in shared mailboxes.
800 questions
Microsoft Graph SDK
Microsoft Graph SDK
A Microsoft software developer kit designed to simplify building high-quality, efficient, and resilient applications that access Microsoft Graph.
884 questions
0 comments No comments
{count} votes

2 answers

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

    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.

  2. CarlZhao-MSFT 23,361 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.