Skip to content

Latest commit

 

History

History
325 lines (274 loc) · 13.2 KB

user-update-mailboxsettings.md

File metadata and controls

325 lines (274 loc) · 13.2 KB
titledescriptionms.localizationpriorityauthorms.subservicedoc_typems.date
Update user mailbox settings
Update one or more settings for the user's mailbox. This includes settings for automatic replies (notify people automatically upon receipt of their email), locale (language and country/region), time zone, and working hours.
medium
SuryaLashmiS
outlook
apiPageType
06/21/2024

Update user mailbox settings

Namespace: microsoft.graph

Enable, configure, or disable one or more of the following settings as part of a user's mailboxSettings:

  • automatic replies (notify people automatically upon receipt of their email)
  • dateFormat
  • delegateMeetingMessageDeliveryOptions
  • locale (language and country/region)
  • timeFormat
  • time zone
  • working hours

When updating the preferred date or time format for a user, specify it in respectively, the short date or short time format.

When updating the preferred time zone for a user, specify it in the Windows or Internet Assigned Numbers Authority (IANA) time zone (also known as Olson time zone) format. You can also further customize the time zone as shown in example 2 below.

Tip

You cannot create or delete any mailbox settings.

[!INCLUDE national-cloud-support]

Permissions

Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

[!INCLUDE permissions-table]

HTTP request

PATCH /me/mailboxSettingsPATCH /users/{id|userPrincipalName}/mailboxSettings

Optional query parameters

This method supports the OData Query Parameters to help customize the response.

Request headers

NameTypeDescription
AuthorizationstringBearer {token}. Required. Learn more about authentication and authorization.

Request body

In the request body, supply the values for the relevant properties that should be updated. Existing properties that are not included in the request body will maintain their previous values or be recalculated based on changes to other property values. For best performance you shouldn't include existing values that haven't changed. The following are the writable/updatable properties:

PropertyTypeDescription
automaticRepliesSettingautomaticRepliesSettingConfiguration settings to automatically notify the sender of an incoming email with a message from the signed-in user. You can set such notifications for only a future date range.
dateFormatstringThe date format for the user's mailbox.
delegateMeetingMessageDeliveryOptionsdelegateMeetingMessageDeliveryOptionsIf the user has a calendar delegate, this specifies whether the delegate, mailbox owner, or both receive meeting messages and meeting responses. Possible values are: sendToDelegateAndInformationToPrincipal, sendToDelegateAndPrincipal, sendToDelegateOnly.
languagelocaleInfoThe locale information for the user, including the preferred language and country/region.
timeFormatstringThe time format for the user's mailbox.
timeZonestringThe default time zone for the user's mailbox.
workingHoursworkingHoursThe hours, days of a week, and time zone that the user works.

Response

If successful, this method returns a 200 OK response code and the updated properties of a mailboxSettings object in the response body.

Errors

Setting working hours with inappropriate values may return the following errors.

ScenarioHTTP status codeError codeError message
Invalid startTime or endTime400RequestBodyReadCannot convert the literal '08' to the expected type 'Edm.TimeOfDay'.
Start time is greater than end time400ErrorInvalidTimeSettingsStart Time should occur before End Time.
Invalid day in daysOfWeek400InvalidArgumentsRequested value 'RandomDay' was not found.
Invalid timeZone400InvalidTimeZoneTime Zone settings provided are invalid.

Examples

Example 1

Request

The first example enables automatic replies for a date range, by setting the following properties of the automaticRepliesSetting property: status, scheduledStartDateTime and scheduledEndDateTime.

PATCH https://graph.microsoft.com/v1.0/me/mailboxSettingsContent-Type: application/json { "@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" } } }

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]


Response

The response includes the updated settings for automatic replies. Note: The response object shown here might be shortened for readability.

HTTP/1.1 200 OKContent-type: application/json { "@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" } }

Example 2

Request

The second example customizes the time zone for the working hours of the signed-in user, by setting the timeZone property to a custom time zone.

PATCH https://graph.microsoft.com/v1.0/me/mailboxSettingsContent-Type: application/json { "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          }      } }

[!INCLUDE snippet-not-available] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE snippet-not-available] [!INCLUDE sdk-documentation]

[!INCLUDE snippet-not-available] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE snippet-not-available] [!INCLUDE sdk-documentation]

[!INCLUDE snippet-not-available] [!INCLUDE sdk-documentation]

[!INCLUDE snippet-not-available] [!INCLUDE sdk-documentation]


Response

The following example shows the response. Note: The response object shown here might be shortened for readability.

HTTP/1.1 200 OKContent-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 } } } }
close