msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

v5 doesn't know well-known folder names

Open olivermue opened this issue 2 years ago • 6 comments

Is your feature request related to a problem? Please describe. In v4 you could write

var mails = await client.Me.MailFolders.SentItems.Request().GetAsync();

In v5 this becomes

var mails = await client.Me.MailFolders["SentItems"].GetAsync();

Unfortunately the list of well-known folder names or no longer part of the SDK and must be taken as string from the documentation.

Describe the solution you'd like Would be great if the v5 SDK also has one of these:

var mails = await client.Me.MailFolders.SentItems.GetAsync();
// or
var mails = await client.Me.MailFolders[MailFolder.SentItems].GetAsync();

olivermue avatar Mar 15 '23 14:03 olivermue

@olivermue Noticed the same yesterday. And tried await client.Me.MailFolders["SentItems"].GetAsync();

But messages are always null. But this works for you?

v4 worked for me.

benjamin79 avatar Mar 15 '23 14:03 benjamin79

Calling client.Me.MailFolders["SentItems"].GetAsync() just returns information about the folder itself. The property messages is not filled by default. Either call the messages explicit (preferred, cause otherwise you can't iterate through the whole collection) or use the expand parameter:

var messages = await client.Me.MailFolders["SentItems"].Messages.GetAsync();
var folderWithMessages = await client.Me.MailFolders["SentItems"].GetAsync(config => config.QueryParameters.Expand = "messages");

But just found out, that the expand parameter is also missing in MailFolderItemRequestBuilderGetQueryParameters. 🙁

olivermue avatar Mar 19 '23 14:03 olivermue