更新用户的首选日期或时间格式时,请分别以
短日期
或
短时间
格式指定它。
更新用户的首选时区时,请在 Windows 或
Internet 号码分配机构 (IANA) 时区
(也称为 Olson 时区) 格式指定它。 还可以进一步自定义时区,如以下示例
2
所示。
无法创建或删除任何邮箱设置。
此 API 可用于以下
国家级云部署
。
美国政府 L4
美国政府 L5 (DOD)
由世纪互联运营的中国
delegateMeetingMessageDeliveryOptions
delegateMeetingMessageDeliveryOptions
如果用户具有日历代理人,这将指定是代理人、邮箱所有者还是同时接收会议消息和会议响应。 可取值为:
sendToDelegateAndInformationToPrincipal
、
sendToDelegateAndPrincipal
、
sendToDelegateOnly
。
language
localeInfo
用户的区域设置信息,包括首选语言和国家/地区。
timeFormat
string
用户邮箱的时间格式。
timeZone
string
用户邮箱的默认时区。
workingHours
workingHours
用户工作的小时数、一周的天数和时区。
如果成功,此方法在
200 OK
响应正文中返回响应代码和
mailboxSettings
对象的更新属性。
将工作时间设置为不适当的值可能会返回以下错误。
HTTP 状态代码
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Me/mailboxSettings",
"automaticRepliesSetting": {
"status": "Scheduled",
"scheduledStartDateTime": {
"dateTime": "2016-03-20T18:00:00.0000000",
"timeZone": "UTC"
"scheduledEndDateTime": {
"dateTime": "2016-03-28T18:00:00.0000000",
"timeZone": "UTC"
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new MailboxSettings
AutomaticRepliesSetting = new AutomaticRepliesSetting
Status = AutomaticRepliesStatus.Scheduled,
ScheduledStartDateTime = new DateTimeTimeZone
DateTime = "2016-03-20T18:00:00.0000000",
TimeZone = "UTC",
ScheduledEndDateTime = new DateTimeTimeZone
DateTime = "2016-03-28T18:00:00.0000000",
TimeZone = "UTC",
AdditionalData = new Dictionary<string, object>
"@odata.context" , "https://graph.microsoft.com/v1.0/$metadata#Me/mailboxSettings"
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.MailboxSettings.PatchAsync(requestBody);
mgc users mailbox-settings patch --user-id {user-id} --body '{\
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Me/mailboxSettings",\
"automaticRepliesSetting": {\
"status": "Scheduled",\
"scheduledStartDateTime": {\
"dateTime": "2016-03-20T18:00:00.0000000",\
"timeZone": "UTC"\
"scheduledEndDateTime": {\
"dateTime": "2016-03-28T18:00:00.0000000",\
"timeZone": "UTC"\
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
requestBody := graphmodels.NewMailboxSettings()
automaticRepliesSetting := graphmodels.NewAutomaticRepliesSetting()
status := graphmodels.SCHEDULED_AUTOMATICREPLIESSTATUS
automaticRepliesSetting.SetStatus(&status)
scheduledStartDateTime := graphmodels.NewDateTimeTimeZone()
dateTime := "2016-03-20T18:00:00.0000000"
scheduledStartDateTime.SetDateTime(&dateTime)
timeZone := "UTC"
scheduledStartDateTime.SetTimeZone(&timeZone)
automaticRepliesSetting.SetScheduledStartDateTime(scheduledStartDateTime)
scheduledEndDateTime := graphmodels.NewDateTimeTimeZone()
dateTime := "2016-03-28T18:00:00.0000000"
scheduledEndDateTime.SetDateTime(&dateTime)
timeZone := "UTC"
scheduledEndDateTime.SetTimeZone(&timeZone)
automaticRepliesSetting.SetScheduledEndDateTime(scheduledEndDateTime)
requestBody.SetAutomaticRepliesSetting(automaticRepliesSetting)
additionalData := map[string]interface{}{
"@odata.context" : "https://graph.microsoft.com/v1.0/$metadata#Me/mailboxSettings",
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
mailboxSettings, err := graphClient.Me().MailboxSettings().Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
MailboxSettings mailboxSettings = new MailboxSettings();
AutomaticRepliesSetting automaticRepliesSetting = new AutomaticRepliesSetting();
automaticRepliesSetting.setStatus(AutomaticRepliesStatus.Scheduled);
DateTimeTimeZone scheduledStartDateTime = new DateTimeTimeZone();
scheduledStartDateTime.setDateTime("2016-03-20T18:00:00.0000000");
scheduledStartDateTime.setTimeZone("UTC");
automaticRepliesSetting.setScheduledStartDateTime(scheduledStartDateTime);
DateTimeTimeZone scheduledEndDateTime = new DateTimeTimeZone();
scheduledEndDateTime.setDateTime("2016-03-28T18:00:00.0000000");
scheduledEndDateTime.setTimeZone("UTC");
automaticRepliesSetting.setScheduledEndDateTime(scheduledEndDateTime);
mailboxSettings.setAutomaticRepliesSetting(automaticRepliesSetting);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("@odata.context", "https://graph.microsoft.com/v1.0/$metadata#Me/mailboxSettings");
mailboxSettings.setAdditionalData(additionalData);
MailboxSettings result = graphClient.me().mailboxSettings().patch(mailboxSettings);
const mailboxSettings = {
'@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#Me/mailboxSettings',
automaticRepliesSetting: {
status: 'Scheduled',
scheduledStartDateTime: {
dateTime: '2016-03-20T18:00:00.0000000',
timeZone: 'UTC'
scheduledEndDateTime: {
dateTime: '2016-03-28T18:00:00.0000000',
timeZone: 'UTC'
await client.api('/me/mailboxSettings')
.update(mailboxSettings);
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\MailboxSettings;
use Microsoft\Graph\Generated\Models\AutomaticRepliesSetting;
use Microsoft\Graph\Generated\Models\AutomaticRepliesStatus;
use Microsoft\Graph\Generated\Models\DateTimeTimeZone;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new MailboxSettings();
$automaticRepliesSetting = new AutomaticRepliesSetting();
$automaticRepliesSetting->setStatus(new AutomaticRepliesStatus('scheduled'));
$automaticRepliesSettingScheduledStartDateTime = new DateTimeTimeZone();
$automaticRepliesSettingScheduledStartDateTime->setDateTime('2016-03-20T18:00:00.0000000');
$automaticRepliesSettingScheduledStartDateTime->setTimeZone('UTC');
$automaticRepliesSetting->setScheduledStartDateTime($automaticRepliesSettingScheduledStartDateTime);
$automaticRepliesSettingScheduledEndDateTime = new DateTimeTimeZone();
$automaticRepliesSettingScheduledEndDateTime->setDateTime('2016-03-28T18:00:00.0000000');
$automaticRepliesSettingScheduledEndDateTime->setTimeZone('UTC');
$automaticRepliesSetting->setScheduledEndDateTime($automaticRepliesSettingScheduledEndDateTime);
$requestBody->setAutomaticRepliesSetting($automaticRepliesSetting);
$additionalData = [
'@odata.context' => 'https://graph.microsoft.com/v1.0/$metadata#Me/mailboxSettings',
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->me()->mailboxSettings()->patch($requestBody)->wait();
$params = @{
"@odata.context" = "https://graph.microsoft.com/v1.0/$metadata#Me/mailboxSettings"
automaticRepliesSetting = @{
status = "Scheduled"
scheduledStartDateTime = @{
dateTime = "2016-03-20T18:00:00.0000000"
timeZone = "UTC"
scheduledEndDateTime = @{
dateTime = "2016-03-28T18:00:00.0000000"
timeZone = "UTC"
# A UPN can also be used as -UserId.
Update-MgUserMailboxSetting -UserId $userId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.mailbox_settings import MailboxSettings
from msgraph.generated.models.automatic_replies_setting import AutomaticRepliesSetting
from msgraph.generated.models.automatic_replies_status import AutomaticRepliesStatus
from msgraph.generated.models.date_time_time_zone import DateTimeTimeZone
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = MailboxSettings(
automatic_replies_setting = AutomaticRepliesSetting(
status = AutomaticRepliesStatus.Scheduled,
scheduled_start_date_time = DateTimeTimeZone(
date_time = "2016-03-20T18:00:00.0000000",
time_zone = "UTC",
scheduled_end_date_time = DateTimeTimeZone(
date_time = "2016-03-28T18:00:00.0000000",
time_zone = "UTC",
additional_data = {
"@odata_context" : "https://graph.microsoft.com/v1.0/$metadata#Me/mailboxSettings",
result = await graph_client.me.mailbox_settings.patch(request_body)
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Me/mailboxSettings",
"automaticRepliesSetting": {
"status": "scheduled",
"externalAudience": "all",
"scheduledStartDateTime": {
"dateTime": "2016-03-20T02:00:00.0000000",
"timeZone": "UTC"
"scheduledEndDateTime": {
"dateTime": "2016-03-28T02: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
属性设置为
自定义时区
,为登录用户的工作时间自定义时区。
"@odata.type": "#microsoft.graph.customTimeZone",
"bias":-300,
"name": "Customized Time Zone",
"standardOffset":{
"time":"02:00:00.0000000",
"dayOccurrence":2,
"dayOfWeek":"Sunday",
"month":10,
"year":0
"daylightOffset":{
"daylightBias":100,
"time":"02:00:00.0000000",
"dayOccurrence":4,
"dayOfWeek":"Sunday",
"month":5,
"year":0
mgc users mailbox-settings patch --user-id {user-id} --body '{\
"workingHours": {\
"endTime" : "18:30:00.0000000", \
"daysOfWeek": [ \
"Monday", \
"Tuesday", \
"Wednesday", \
"Thursday", \
"Friday", \
"Saturday" \
"timeZone" : { \
"@odata.type": "#microsoft.graph.customTimeZone", \
"bias":-300, \
"name": "Customized Time Zone",\
"standardOffset":{ \
"time":"02:00:00.0000000", \
"dayOccurrence":2, \
"dayOfWeek":"Sunday", \
"month":10, \
"year":0 \
"daylightOffset":{ \
"daylightBias":100, \
"time":"02:00:00.0000000", \
"dayOccurrence":4, \
"dayOfWeek":"Sunday", \
"month":5, \
"year":0 \
'@odata.type': '#microsoft.graph.customTimeZone',
bias: -300,
name: 'Customized Time Zone',
standardOffset: {
time: '02:00:00.0000000',
dayOccurrence: 2,
dayOfWeek: 'Sunday',
month: 10,
year: 0
daylightOffset: {
daylightBias: 100,
time: '02:00:00.0000000',
dayOccurrence: 4,
dayOfWeek: 'Sunday',
month: 5,
year: 0
await client.api('/me/mailboxSettings')
.update(mailboxSettings);
"@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