🔍 Code Extractor

class InternetMessageHeader

Maturity: 53

A class representing an Internet message header as a key-value pair, conforming to RFC5322 standards for email message headers.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/messages/internet_header.py
Lines:
4 - 16
Complexity:
simple

Purpose

This class models Internet message headers used in email and other messaging protocols. It encapsulates the header name (key) and value pair that describes network path information and metadata about messages as they travel from sender to recipient. It inherits from ClientValue, suggesting it's part of a larger Office 365 API client library for handling message-related data structures.

Source Code

class InternetMessageHeader(ClientValue):
    """
    A key-value pair that represents an Internet message header, as defined by RFC5322, that provides details of the
    network path taken by a message from the sender to the recipient.
    """

    def __init__(self, name=None, value=None):
        """
        :param str name: Represents the key in a key-value pair.
        :param str value:The value in a key-value pair.
        """
        self.name = name
        self.value = value

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

name: The header field name (key) as a string. This represents the identifier for the header (e.g., 'From', 'To', 'Subject', 'Received'). Can be None if not yet set. Should follow RFC5322 naming conventions for message headers.

value: The header field value as a string. This contains the actual data associated with the header name (e.g., email addresses, dates, message IDs). Can be None if not yet set. The format depends on the specific header type.

Return Value

Instantiation returns an InternetMessageHeader object with the specified name and value attributes. The object represents a single header field from an Internet message and can be used to store, retrieve, or transmit header information within the Office 365 API context.

Class Interface

Methods

__init__(name=None, value=None)

Purpose: Constructor that initializes an InternetMessageHeader instance with optional name and value

Parameters:

  • name: Optional string representing the header field name (key). Defaults to None.
  • value: Optional string representing the header field value. Defaults to None.

Returns: None (constructor)

Attributes

Name Type Description Scope
name str or None The header field name (key) that identifies the type of header (e.g., 'From', 'To', 'Subject'). Represents the key in the key-value pair. instance
value str or None The header field value containing the actual data associated with the header name. Represents the value in the key-value pair. instance

Dependencies

  • office365

Required Imports

from office365.runtime.client_value import ClientValue
from office365.outlook.mail.internet_message_header import InternetMessageHeader

Usage Example

from office365.outlook.mail.internet_message_header import InternetMessageHeader

# Create a simple message header
header = InternetMessageHeader(name='X-Custom-Header', value='CustomValue')
print(f'Header: {header.name} = {header.value}')

# Create a standard email header
from_header = InternetMessageHeader(name='From', value='sender@example.com')
to_header = InternetMessageHeader(name='To', value='recipient@example.com')

# Create with default None values
empty_header = InternetMessageHeader()
empty_header.name = 'Subject'
empty_header.value = 'Meeting Reminder'

# Typical usage in message context
headers = [
    InternetMessageHeader('Date', 'Mon, 1 Jan 2024 12:00:00 +0000'),
    InternetMessageHeader('Message-ID', '<unique-id@example.com>'),
    InternetMessageHeader('Received', 'from mail.example.com by server.example.com')
]

Best Practices

  • Always provide both name and value when creating headers for complete message metadata
  • Follow RFC5322 standards for header field names (case-insensitive, typically capitalized with hyphens)
  • Header names should not contain spaces or special characters except hyphens
  • Be aware that this class inherits from ClientValue, which may provide serialization/deserialization capabilities for API communication
  • When working with standard headers (From, To, Subject, etc.), ensure values conform to expected formats
  • This is a simple data container class with no validation - ensure data integrity at the application level
  • The class is immutable in design but attributes can be modified after instantiation - consider treating instances as immutable for thread safety
  • Typically used as part of a collection of headers rather than standalone
  • No method call order dependencies - this is a pure data class

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class Message 57.9% similar

    Represents an email message in a Microsoft Outlook mailbox folder, providing methods for message operations like sending, replying, forwarding, and managing attachments.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/messages/message.py
  • class EmailAddress 57.3% similar

    A data class representing an email address with an associated display name, inheriting from ClientValue for use in Office 365 API operations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/email_address.py
  • class Recipient 55.8% similar

    A class representing information about a user in the sending or receiving end of an event, message or group post in Microsoft Office 365 Outlook.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/recipient.py
  • class AttachmentItem 53.7% similar

    A data class representing metadata attributes of an attachment item, including its type, name, and size.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/attachments/attachment_item.py
  • class MessageRulePredicates 52.6% similar

    A data class representing conditions and exceptions for email message rules in Microsoft Outlook, inheriting from ClientValue.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/messages/rules/predicates.py
← Back to Browse