class OutlookCategory
Represents an Outlook category used to group and organize Outlook items such as messages and events in a user's mailbox.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/category.py
4 - 18
simple
Purpose
This class models an Outlook category entity that allows users to organize their Outlook items. Categories are defined in a master list and can be applied to various Outlook items. Each category has a unique display name and an associated color constant. The class inherits from Entity and provides read-only access to category properties through Python properties.
Source Code
class OutlookCategory(Entity):
"""Represents a category by which a user can group Outlook items such as messages and events.
The user defines categories in a master list, and can apply one or more
of these user-defined categories to an item."""
@property
def color(self):
"""A pre-set color constant that characterizes a category, and that is mapped to one of 25 predefined colors"""
return self.properties.get("color", None)
@property
def display_name(self):
"""A unique name that identifies a category in the user's mailbox.
After a category is created, the name cannot be changed"""
return self.properties.get("displayName", None)
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
Entity_base_class: Inherits from Entity base class which likely provides common functionality for Microsoft Graph API entities, including property storage and management
Return Value
Instantiation returns an OutlookCategory object that represents a category entity. The properties (color and display_name) return their respective values from the internal properties dictionary, or None if not present.
Class Interface
Methods
@property color(self) -> Optional[str]
property
Purpose: Returns the pre-set color constant that characterizes the category, mapped to one of 25 predefined colors
Returns: A color constant string or None if not set
@property display_name(self) -> Optional[str]
property
Purpose: Returns the unique name that identifies the category in the user's mailbox
Returns: The category's display name string or None if not set. This name cannot be changed after creation
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
properties |
dict | Inherited from Entity base class. Stores the category's properties including color and displayName as retrieved from the Microsoft Graph API | instance |
Dependencies
office365
Required Imports
from office365.entity import Entity
from office365.outlook.category import OutlookCategory
Usage Example
# Assuming you have an authenticated Office365 client
# and access to the user's categories collection
# Retrieve a category (typically done through Office365 client)
category = outlook_client.me.outlook.master_categories.get_by_id('category_id').execute_query()
# Access category properties
color = category.color # Returns the pre-set color constant
display_name = category.display_name # Returns the unique category name
print(f"Category: {display_name}, Color: {color}")
# Note: Categories are typically retrieved from the master list
# and cannot have their display_name changed after creation
Best Practices
- This class is read-only; properties are accessed but not modified directly through this interface
- The display_name is immutable after category creation and serves as the unique identifier
- Categories should be retrieved through the Office365 client's master categories collection
- The color property maps to one of 25 predefined color constants in Outlook
- This class inherits from Entity, so it likely has additional methods and properties from the base class for property management and API interactions
- Do not attempt to instantiate this class directly; it should be created through the Office365 API client
- Both properties return None if the corresponding data is not available in the properties dictionary
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class OutlookUser 71.5% similar
-
class OutlookItem 71.3% similar
-
class MailFolder 62.8% similar
-
class MessageRule 57.6% similar
-
class Message 56.5% similar