获取用户的邮箱设置

命名空间:microsoft.graph

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

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

用户可以使用 Outlook 网页版设置首选的日期和时间格式。 用户可以选择支持的短日期短时间格式之一。 此 GET 操作将返回用户选择的格式。

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

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

此 API 可用于以下国家级云部署

全局服务 美国政府 L4 美国政府 L5 (DOD) 由世纪互联运营的中国

权限

为此 API 选择标记为最低特权的权限。 只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考

权限类型 最低特权权限 更高特权权限
委派(工作或学校帐户) MailboxSettings.Read MailboxSettings.ReadWrite
委派(个人 Microsoft 帐户) MailboxSettings.Read MailboxSettings.ReadWrite
应用程序 MailboxSettings.Read MailboxSettings.ReadWrite

HTTP 请求

若要获取用户的所有邮箱设置:

GET /me/mailboxSettings
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 查询参数 来帮助自定义响应。

请求标头

名称 类型 说明
Authorization string 持有者 {token}。 必填。

请求正文

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

响应

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

示例

示例 1:获取已登录用户邮箱的所有邮箱设置

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

请求

以下示例显示了一个请求。

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

响应

下面是包含已登录用户的所有邮箱设置的响应示例。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

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)"
    },
    "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:专门获取已登录用户邮箱的自动答复设置

请求

以下示例显示了一个请求。

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

响应

下面是仅包含自动答复设置的响应示例。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

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

{
    "@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:获取已登录用户邮箱的工作时间设置

请求

以下示例显示了一个请求。

GET https://graph.microsoft.com/v1.0/me/mailboxSettings/workingHours

响应

下面是仅包含工作时间设置的响应示例。 请注意,用户的工作时间在自定义时区内。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

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

{
    "@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:专门获取已登录用户邮箱的用户用途设置

请求

以下示例显示了一个请求。

GET https://graph.microsoft.com/v1.0/me/mailboxSettings/userPurpose

响应

下面是仅包含 用户用途 设置的响应示例。

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

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('622eaaff-0683-4862-9de4-f2ec83c2bd98')/mailboxSettings/userPurpose",
    "value": "user"
}