获取用户的邮箱设置

获取用户的 mailboxSettings。这包括自动答复(收到发件人的电子邮件时自动通知发件人)、区域设置(语言和国家/地区)和时区设置。

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

先决条件

要执行此 API,需要以下范围Mailboxsettings.ReadWrite

HTTP 请求

获取包括自动答复设置的所有邮箱设置:

GET /me/mailboxSettings
GET /users/{id|userPrincipalName}/mailboxSettings

获取特定设置,例如,仅获取自动答复设置、区域设置或时区:

GET /me/mailboxSettings/automaticRepliesSetting
GET /users/{id|userPrincipalName}/mailboxSettings/automaticRepliesSetting

GET /me/mailboxSettings/language
GET /users/{id|userPrincipalName}/mailboxSettings/language

GET /me/mailboxSettings/timeZone
GET /users/{id|userPrincipalName}/mailboxSettings/timeZone

可选的查询参数

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

请求标头

名称 类型 说明
Authorization string Bearer <token>. Required.

请求正文

请勿提供此方法的请求正文。

响应

如果成功,此方法在响应正文中返回 200 OK 响应代码和以下请求对象之一:

示例

请求 1

第一个示例获取已登录用户邮箱的所有邮箱设置,其中包括自动答复设置、时区和语言设置。

GET https://graph.microsoft.com/v1.0/me/mailboxSettings
响应 1

该响应包括所有的邮箱设置。注意:为了简单起见,可能会将此处所示的响应对象截断。将从实际调用中返回所有属性。

HTTP/1.1 200 OK
Content-type: application/json

{
    "@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)"
    }
}
请求 2

第二个示例专门获取已登录用户邮箱的自动答复设置。

GET https://graph.microsoft.com/v1.0/me/mailboxSettings/automaticRepliesSetting
响应 2

该响应仅包括自动答复设置。注意:为了简单起见,可能会将此处所示的响应对象截断。将从实际调用中返回所有属性。

HTTP/1.1 200 OK
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/api/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"
}