Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does the Microsoft Graph .NET client library (Microsoft Graph API) support filtering messages by body content and creation date? #1079

Closed
HorbachAnton opened this issue Jul 29, 2021 · 3 comments

Comments

@HorbachAnton
Copy link

HorbachAnton commented Jul 29, 2021

I am using this library in my project to retrieve emails from my mailbox. However, when I try to filter messages from my mailbox by createdDateTime I get a "Bad Request" error. Here is my request:

private static IMailFolderMessagesCollectionPage GetMessages(string subject, int count) { return new graphServiceClient.Me.MailFolders.Inbox.Messages.Request().Filter($"subject eq '{subject}' and createdDateTime gt '{DateTime.Now.AddMinutes(-10)}'").Top(count).GetAsync().Result; }

Also, when I try to retrieve an email by its subject and body content - I can't get any message. Here is my request:

private static IMailFolderMessagesCollectionPage GetMessages(string subject, string bodyPart, int count) { return new graphServiceClient.Me.MailFolders.Inbox.Messages.Request().Filter($"subject eq '{subject}' and contains(body/content, '{bodyPart}')").Top(count).GetAsync().Result; }

Do the Microsoft Graph API and the library itself support filtering of emails(messages) by createdDateTime and body content?
AB#10435

@ghost ghost added the Needs: Triage label Jul 29, 2021
@ghost ghost added this to Issues to triage in Graph SDK - DotNet Jul 29, 2021
@andrueastman
Copy link
Member

Hey @HorbachAnton,
Thanks for raising this issue.

The filter operation is actually done on the API side and not really a function of the client library.

Any chance you have first tried constructing the desired query on Graph Explorer to confirm if you get similar results?

@HorbachAnton
Copy link
Author

I've constructed the desired query on Graph Explorer and got the similar results. There are no messages in reply. My query.

https://graph.microsoft.com/v1.0/me/mailFolders('Inbox')/messages?$filter=subject eq '*****' and contains(body/content, '****')&$top=10

Do I understand correctly that a construct like 'contains(body/content, '****')' verifies that the body contains the object I specified? And the whole body of the object shouldn't just consist of it?

@andrueastman
Copy link
Member

Hey @HorbachAnton,

As this functionality is not part of the client library, I have forwarded your question at the link below, so that the relevant API owners can help us understand if this is indeed expected behavior.

https://docs.microsoft.com/en-us/answers/questions/495540/support-filtering-messages-by-body-content.html

I will close this issue for now so that we may continue to follow this up from there.

Graph SDK - DotNet automation moved this from Issues to triage to Completed Jul 30, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Feb 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Graph SDK - DotNet
  
Completed
Development

No branches or pull requests

2 participants