class OutlookUser
Represents the Outlook services available to a user, providing access to user-specific Outlook settings, categories, supported languages, and time zones.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/user.py
12 - 59
moderate
Purpose
This class serves as a wrapper for Microsoft Outlook user-related operations within the Office365 API. It extends the Entity base class and provides methods to query supported languages and time zones configured on the user's mailbox server, as well as access to the user's master categories. The class is designed to work within a context-based query system where operations are added to a query queue and executed by the underlying framework.
Source Code
class OutlookUser(Entity):
"""Represents the Outlook services available to a user."""
def supported_languages(self):
"""
Get the list of locales and languages that are supported for the user, as configured on the user's
mailbox server. When setting up an Outlook client, the user selects the preferred language from this supported
list. You can subsequently get the preferred language by getting the user's mailbox settings.
"""
return_type = ClientResult(self.context, ClientValueCollection(LocaleInfo))
qry = FunctionQuery(self, "supportedLanguages", None, return_type)
self.context.add_query(qry)
return return_type
def supported_time_zones(self):
"""
Get the list of time zones that are supported for the user, as configured on the user's mailbox server.
You can explicitly specify to have time zones returned in the Windows time zone format or
Internet Assigned Numbers Authority (IANA) time zone (also known as Olson time zone) format.
The Windows format is the default.
When setting up an Outlook client, the user selects the preferred time zone from this supported list.
You can subsequently get the preferred time zone by getting the user's mailbox settings.
"""
return_type = ClientResult(
self.context, ClientValueCollection(TimeZoneInformation)
)
qry = FunctionQuery(self, "supportedTimeZones", None, return_type)
self.context.add_query(qry)
return return_type
@property
def master_categories(self):
# type: () -> EntityCollection[OutlookCategory]
"""A list of categories defined for the user."""
return self.properties.get(
"masterCategories",
EntityCollection(
self.context,
OutlookCategory,
ResourcePath("masterCategories", self.resource_path),
),
)
def get_property(self, name, default_value=None):
if default_value is None:
property_mapping = {"masterCategories": self.master_categories}
default_value = property_mapping.get(name, None)
return super(OutlookUser, self).get_property(name, default_value)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
context: The execution context inherited from Entity base class, used for managing API requests and maintaining connection state with the Office365 service
resource_path: The resource path inherited from Entity base class that identifies the specific user resource in the Office365 API hierarchy
Return Value
Instantiation returns an OutlookUser object that represents a specific user's Outlook services. The supported_languages() method returns a ClientResult containing a ClientValueCollection of LocaleInfo objects. The supported_time_zones() method returns a ClientResult containing a ClientValueCollection of TimeZoneInformation objects. The master_categories property returns an EntityCollection of OutlookCategory objects representing the user's defined categories.
Class Interface
Methods
supported_languages(self) -> ClientResult
Purpose: Retrieves the list of locales and languages supported for the user as configured on their mailbox server
Returns: ClientResult containing a ClientValueCollection of LocaleInfo objects representing supported languages and locales
supported_time_zones(self) -> ClientResult
Purpose: Retrieves the list of time zones supported for the user as configured on their mailbox server, in Windows or IANA format
Returns: ClientResult containing a ClientValueCollection of TimeZoneInformation objects representing supported time zones
get_property(self, name: str, default_value=None) -> Any
Purpose: Retrieves a property value by name with support for property mapping and default values
Parameters:
name: The name of the property to retrievedefault_value: Optional default value to return if property is not found; if None, uses internal property mapping
Returns: The property value if found, otherwise the default_value or mapped value from property_mapping
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
master_categories |
EntityCollection[OutlookCategory] | A collection of categories defined for the user in Outlook, lazily loaded from the 'masterCategories' property | instance |
context |
ClientContext | The execution context inherited from Entity base class, manages API requests and connection state | instance |
resource_path |
ResourcePath | The resource path inherited from Entity base class that identifies this user resource in the API hierarchy | instance |
properties |
dict | Dictionary storing the entity's properties, inherited from Entity base class | instance |
Dependencies
office365
Required Imports
from office365.entity import Entity
from office365.entity_collection import EntityCollection
from office365.outlook.category import OutlookCategory
from office365.outlook.locale_info import LocaleInfo
from office365.outlook.timezone_information import TimeZoneInformation
from office365.runtime.client_result import ClientResult
from office365.runtime.client_value_collection import ClientValueCollection
from office365.runtime.paths.resource_path import ResourcePath
from office365.runtime.queries.function import FunctionQuery
Usage Example
from office365.graph_client import GraphClient
from office365.outlook.user import OutlookUser
# Authenticate and get client
client = GraphClient.with_token(lambda: 'your_access_token')
# Get the current user's Outlook services
outlook_user = client.me.outlook
# Get supported languages
languages_result = outlook_user.supported_languages()
client.execute_query()
for locale in languages_result.value:
print(f"Language: {locale.display_name}")
# Get supported time zones
timezones_result = outlook_user.supported_time_zones()
client.execute_query()
for tz in timezones_result.value:
print(f"Time Zone: {tz.display_name}")
# Access master categories
categories = outlook_user.master_categories
client.load(categories)
client.execute_query()
for category in categories:
print(f"Category: {category.display_name}")
Best Practices
- Always call execute_query() on the context after invoking methods that return ClientResult to actually execute the queued operations
- The class uses lazy loading for properties like master_categories - ensure you load them explicitly if needed
- Methods like supported_languages() and supported_time_zones() add queries to the context queue but don't execute immediately
- The class is designed to be obtained through the Office365 client hierarchy (e.g., client.me.outlook) rather than instantiated directly
- Handle authentication and token refresh appropriately as all operations require valid Office365 credentials
- The get_property method provides a property mapping mechanism - use it when accessing properties dynamically
- Time zones can be returned in Windows or IANA format - Windows format is the default
- Results are wrapped in ClientResult objects which contain the actual data in their 'value' property after query execution
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class OutlookCategory 71.5% similar
-
class OutlookItem 67.7% similar
-
class WorkingHours 66.5% similar
-
class MailFolder 59.5% similar
-
class Recipient 58.7% similar