如何使用 Graph SDK 获取用户的邮箱设置
How to grab a user's mailbox setting using the Graph SDK
我在尝试使用此处的 Graph 客户端库获取此数据时遇到问题:https://www.nuget.org/packages/Microsoft.Graph in my c# application. I'm aware that the data is available using this REST API call。
我已经创建了我的 Azure 应用程序并提供了应用程序 "Read all user mailbox settings" 权限并单击 "grant permissions" 以应用它们。问题不在于我的身份验证。我能够检索数据。
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,但如果可以的话,我只想使用库。
只需将 Select("MailboxSettings") 添加到您的查询中即可。
根据您的代码获取用户的邮箱设置
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;
}
我在尝试使用此处的 Graph 客户端库获取此数据时遇到问题:https://www.nuget.org/packages/Microsoft.Graph in my c# application. I'm aware that the data is available using this REST API call。
我已经创建了我的 Azure 应用程序并提供了应用程序 "Read all user mailbox settings" 权限并单击 "grant permissions" 以应用它们。问题不在于我的身份验证。我能够检索数据。
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,但如果可以的话,我只想使用库。
只需将 Select("MailboxSettings") 添加到您的查询中即可。
根据您的代码获取用户的邮箱设置
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;
}