4

i am working in graph explorer API to read the email of my account. the idea is to pass an email address and a date interval to Graph API and it should return me the same Messages Associated with this email.it could be from sent item and inbox can be both. i am useing below api:

https://graph.microsoft.com/v1.0/me/messages?$Search="Aj****@t**maxa****icas.com
and Sent >= 2018-05-09"

but this is giving Messages from my inbox not from sent Email.Can any 1 help me out. Thanks.

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
ashish jayara
  • 95
  • 1
  • 10

2 Answers2

7

The /me/messages endpoint works against the mailbox but there are exceptions. Certain mail folders are specifically excluded: Outbox, Send Items, Junk, Deleted Items. In general, folders that contain outgoing or otherwise ignored mail (i.e. junk, trash) require special handling.

In order to work against a specific folder, you need to specify that folder in your URL path:

/me/mailFolders/{folder}/messages

The {folder} can be folder's id (obtained by listing the folders via /me/mailFolders) or a "well-known folder name" that is pre-defined by Exchange (ArchiveRoot, ConversationHistory, DeletedItems, Drafts, Inbox, JunkEmail, Outbox, or SentItems).

So to obtain the messages in the Sent Items folder, you would call:

https://graph.microsoft.com/v1.0/me/mailFolders/SentItems/messages
Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
  • @Mark Lafleur : Thanks for your reply but i am not sure in which folder the search email exists . don't we have any solution we can search on entire outlook not only in a specific folder? – ashish jayara May 16 '18 at 09:24
  • Technically `/me/messages` will cover the entire mailbox. There are however some exceptions. I will update my answer. – Marc LaFleur May 16 '18 at 13:57
  • $search="Received>=2018-05-16T11:55:01 AND Participants:A***@tr*****c**as.com"&$top=10 This work fine for me.Thanks – ashish jayara May 16 '18 at 13:59
  • Awesome work, I am looking for same solution but inbox. I want to get all the messages from inbox but issue is that it only show email but I want to have reply email as well of all emails. Thank you. – Cybermakarov Mar 31 '22 at 09:53
1
https://graph.microsoft.com/v1.0/me/mailFolders/SentItems/messages$search="Received>=2018-05-16T11:55:01 AND Participants:A***@tr*****c**as.com"&$top=10 

This works fine for me.

you can pass the yyyy-mm-dd format also in the Revived date.

ashish jayara
  • 95
  • 1
  • 10