2

我在尝试使用此处找到的 Graph 客户端库获取此数据时遇到问题:https ://www.nuget.org/packages/Microsoft.Graph在我的 c# 应用程序中。我知道可以使用此REST API 调用获得数据。

我已经创建了我的天蓝色应用程序并提供了应用程序“读取所有用户邮箱设置”权限并单击“授予权限”以应用它们。问题不在于我的身份验证。我能够检索数据。

MicrosoftAuthenticationProvider authProvider = 
    new MicrosoftAuthenticationProvider(applicationID, applicationSecret, microsoftURL);
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
IGraphServiceUsersCollectionPage users = await graphClient.Users.Request().GetAsync();
foreach (User user in users)
{
    //user.MailboxSettings
    //returns null, but through intellisense, I can obtain it's attributes
    //Microsoft.Graph.MailboxSettings is available in the library's object browser

    //graphClient.Users[user.UserPrincipalName].MailboxSettings.Request().GetAsync() 
    //User.MailboxSettings is not available
}

作为最后的手段,我将使用 REST API,但如果可以,我只想使用该库。

4

1 回答 1

4

只需将Select("MailboxSettings")附加到您的查询中。

根据你的代码获取用户的 MailboxSetting

                IGraphServiceUsersCollectionPage users = await 
                    graphClient.Users.Request().GetAsync();

                foreach (User user in users)
                {
                    User fullUser = await graphClient.Users[user.UserPrincipalName].Request().Select("MailboxSettings").GetAsync();

                    MailboxSettings mailboxSettings1 = fullUser.MailboxSettings;                     
                }

在此处输入图像描述

于 2018-09-22T07:52:45.363 回答