命名空间:microsoft.graph

获取用户的 mailboxSettings 。 可以查看所有邮箱设置或获取特定设置。

用户可通过 Outlook 客户端为其邮箱设置以下设置:

  • 自动答复 (收到发件人的电子邮件时自动通知发件人)
  • delegateMeetingMessageDeliveryOptions
  • 区域设置 (语言和国家/地区)
  • 用户可以使用 Outlook 网页版设置首选的日期和时间格式。 用户可以选择支持的 短日期 短时间 格式之一。 此 GET 操作将返回用户选择的格式。

    通过从管理员为其邮箱服务器设置的 支持时区 中进行选择,用户可以在任何 Outlook 客户端上设置自己喜欢的时区。 管理员可以设置 Windows 时区格式或 Internet 号码分配机构 (IANA) 时区 (也称为 Olson 时区) 格式的时区。 Windows 时区是默认格式。

    GET 操作以管理员设置的格式返回用户的首选时区。 若要将时区设置为某种特定格式(Windows 或 IANA),可以先 将相应格式的首选时区更新为邮箱设置 。 随后便可以获取相应格式的时区。 也可以在应用中单独管理格式转换。

    调用此 API 需要以下权限之一。 若要了解详细信息,包括如何选择权限的信息,请参阅 权限

    权限(从最低特权到最高特权) GET /users/{id|userPrincipalName}/mailboxSettings

    若要获取特定设置 - 仅自动答复设置、日期格式、区域设置、区域设置、时间格式、时区、工作时间或用户的收件人或邮箱类型 (例如,用户用途) :

    GET /me/mailboxSettings/automaticRepliesSetting
    GET /users/{id|userPrincipalName}/mailboxSettings/automaticRepliesSetting
    GET /me/mailboxSettings/dateFormat
    GET /users/{id|userPrincipalName}/mailboxSettings/dateFormat
    GET /me/mailboxSettings/delegateMeetingMessageDeliveryOptions
    GET /users/{id|userPrincipalName}/mailboxSettings/delegateMeetingMessageDeliveryOptions
    GET /me/mailboxSettings/language
    GET /users/{id|userPrincipalName}/mailboxSettings/language
    GET /me/mailboxSettings/timeFormat
    GET /users/{id|userPrincipalName}/mailboxSettings/timeFormat
    GET /me/mailboxSettings/timeZone
    GET /users/{id|userPrincipalName}/mailboxSettings/timeZone
    GET /me/mailboxSettings/workingHours
    GET /users/{id|userPrincipalName}/mailboxSettings/workingHours
    GET /me/mailboxSettings/userPurpose
    GET /users/{id|userPrincipalName}/mailboxSettings/userPurpose
    

    可选的查询参数

    此方法支持一些 OData 查询参数 来帮助自定义响应。

  • automaticRepliesSetting 对象
  • 字符串(适用于 dateFormat
  • delegateMeetingMessageDeliveryOptions) 的字符串 (
  • localeInfo 对象
  • 字符串(适用于 timeFormat
  • 字符串(适用于 timeZone
  • workingHours
  • userPurpose
  • 示例 1:获取已登录用户邮箱的所有邮箱设置

    获取已登录用户邮箱的所有邮箱设置,其中包括自动答复、日期格式、区域设置 (语言和国家/地区) 、时间格式、时区、工作时间和用户用途的设置。

    请求示例如下所示。

    JavaScript const client = Client.init(options); let mailboxSettings = await client.api('/me/mailboxSettings') .get(); GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); MailboxSettings mailboxSettings = graphClient.customRequest("/me/mailboxSettings", MailboxSettings.class) .buildRequest() .get(); "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Me/mailboxSettings", "automaticRepliesSetting": { "status": "Scheduled", "externalAudience": "All", "scheduledStartDateTime": { "dateTime": "2016-03-14T07:00:00.0000000", "timeZone": "UTC" "scheduledEndDateTime": { "dateTime": "2016-03-28T07:00:00.0000000", "timeZone": "UTC" "internalReplyMessage": "<html>\n<body>\n<p>I'm at our company's worldwide reunion and will respond to your message as soon as I return.<br>\n</p></body>\n</html>\n", "externalReplyMessage": "<html>\n<body>\n<p>I'm at the Contoso worldwide reunion and will respond to your message as soon as I return.<br>\n</p></body>\n</html>\n" "timeZone":"UTC", "language":{ "locale":"en-US", "displayName":"English (United States)" "workingHours":{ "daysOfWeek":[ "monday", "tuesday", "wednesday", "thursday", "friday" "startTime": "08:00:00.0000000", "endTime": "17:00:00.0000000", "timeZone":{ "name":"Pacific Standard Time" "userPurpose": { "value": "user" "dateFormat": "MM/dd/yyyy", "timeFormat": "hh:mm tt", "delegateMeetingMessageDeliveryOptions": "sendToDelegateOnly"

    示例 2:专门获取已登录用户邮箱的自动答复设置

    请求示例如下所示。

    JavaScript const client = Client.init(options); let automaticRepliesSetting = await client.api('/me/mailboxSettings/automaticRepliesSetting') .get(); GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); AutomaticRepliesSetting automaticRepliesSetting = graphClient.customRequest("/me/mailboxSettings/automaticRepliesSetting", AutomaticRepliesSetting.class) .buildRequest() .get(); "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Me/mailboxSettings/automaticRepliesSetting", "status": "alwaysEnabled", "externalAudience": "None", "scheduledStartDateTime": { "dateTime": "2016-03-19T02:00:00.0000000", "timeZone": "UTC" "scheduledEndDateTime": { "dateTime": "2016-03-20T02:00:00.0000000", "timeZone": "UTC" "internalReplyMessage": "<html>\n<body>\n<p>I'm at our company's worldwide reunion and will respond to your message as soon as I return.<br>\n</p></body>\n</html>\n", "externalReplyMessage": "<html>\n<body>\n<p>I'm at the Contoso worldwide reunion and will respond to your message as soon as I return.<br>\n</p></body>\n</html>\n"

    示例 3:获取已登录用户邮箱的工作时间设置

    请求示例如下所示。

    JavaScript const client = Client.init(options); let workingHours = await client.api('/me/mailboxSettings/workingHours') .get(); GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); WorkingHours workingHours = graphClient.customRequest("/me/mailboxSettings/workingHours", WorkingHours.class) .buildRequest() .get(); "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('94447c6e-ea4c-494c-a9ed-d905e366c5cb')/mailboxSettings/workingHours", "daysOfWeek":[ "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" "startTime":"09:00:00.0000000", "endTime":"18:30:00.0000000", "timeZone":{ "@odata.type":"#microsoft.graph.customTimeZone", "bias":-200, "name":"Customized Time Zone", "standardOffset":{ "time":"02:00:00.0000000", "dayOccurrence":4, "dayOfWeek":"sunday", "month":5, "year":0 "daylightOffset":{ "daylightBias":-100, "time":"02:00:00.0000000", "dayOccurrence":2, "dayOfWeek":"sunday", "month":10, "year":0

    示例 4:专门获取已登录用户邮箱的用户用途设置

    请求示例如下所示。

    JavaScript const client = Client.init(options); let userPurpose = await client.api('/me/mailboxSettings/userPurpose') .get(); GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient(); UserPurpose userPurpose = graphClient.customRequest("/me/mailboxSettings/userPurpose", UserPurpose.class) .buildRequest() .get(); "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('622eaaff-0683-4862-9de4-f2ec83c2bd98')/mailboxSettings/userPurpose", "value": "user"