Problem searching for specific Mails using MS-Graph API

226 views Asked by At

I have a WPF-Application that uses the MS-Graph API, to search for EMails containing a specific keyword and display them to the user.

To get only the mails a user searches for, the MS-Documentation recomments this:

var messages = await graphClient.Me.Messages
.Request()
.Search("Pizza")
.GetAsync();

The problem is, this doesn't work in my code and I can't figure out why. The only thing my VS tells me is that it could not resolve symbol "search" and I didn't find anything about this problem here or somewhere else on the internet.

The way I'm doing it at the moment is this:

        var queryOption = new List<QueryOption>()
        {
            new QueryOption("$search", "Pizza")
        };
        var messages = await serviceClient.Me.Messages.Request(queryOption).GetAsync();

This works as expected, but does anyone now how to do it as shown in the MS-Documentation?

I would appreciate any help!

1

There are 1 answers

1
Ehssan On BEST ANSWER

Currently, there is no search method available for the IUserMessagesCollectionRequest object, so you are using it correctly. This is also described here:

https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/dev/docs/overview.md#custom-query-options