class MailAssessmentRequest
A class representing a mail threat assessment request that inherits from ThreatAssessmentRequest, used to create and retrieve mail-based security threat assessments in Microsoft 365.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/directory/protection/threatassessment/mail_request.py
6 - 13
moderate
Purpose
This class is used to create and manage mail threat assessment requests within the Microsoft 365 security framework. It allows applications to submit emails for security analysis and retrieve assessment results. The mail must be received by the user specified in recipientEmail, and requires delegated Mail permissions (Mail.Read or Mail.Read.Shared) to access the mail content. This is part of the Microsoft Graph API threat assessment functionality for evaluating potential security threats in email messages.
Source Code
class MailAssessmentRequest(ThreatAssessmentRequest):
"""
Used to create and retrieve a mail threat assessment, derived from threatAssessmentRequest.
When you create a mail threat assessment request, the mail should be received by the user specified
in recipientEmail. Delegated Mail permissions (Mail.Read or Mail.Read.Shared) are requried to access the mail
received by the user or shared by someone else.
"""
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ThreatAssessmentRequest | - |
Parameter Details
__init__: The constructor parameters are inherited from the parent class ThreatAssessmentRequest. Specific parameters are not defined in the provided code snippet, but typically would include properties like recipientEmail, category, contentType, and other threat assessment metadata required by the parent class.
Return Value
Instantiation returns a MailAssessmentRequest object that inherits all methods and properties from ThreatAssessmentRequest. Methods inherited from the parent class would typically return assessment results, status information, or confirmation of request submission.
Class Interface
Methods
__init__(self, **kwargs)
Purpose: Initializes a new MailAssessmentRequest instance, inheriting from ThreatAssessmentRequest
Parameters:
kwargs: Keyword arguments passed to the parent ThreatAssessmentRequest constructor, typically including recipientEmail, category, contentType, and other assessment metadata
Returns: None (constructor)
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
recipient_email |
str | The email address of the user who received the mail being assessed (inherited from parent class) | instance |
category |
str | The threat category for the assessment (e.g., 'spam', 'malware', 'phish') (inherited from parent class) | instance |
status |
str | The current status of the threat assessment request (inherited from parent class) | instance |
results |
collection | Collection of assessment results returned by the threat assessment service (inherited from parent class) | instance |
Dependencies
office365
Required Imports
from office365.directory.protection.threatassessment.request import ThreatAssessmentRequest
from office365.directory.protection.threatassessment.mail_assessment_request import MailAssessmentRequest
Usage Example
from office365.directory.protection.threatassessment.mail_assessment_request import MailAssessmentRequest
from office365.runtime.auth.client_credential import ClientCredential
from office365.graph_client import GraphClient
# Authenticate
credentials = ClientCredential(client_id='your_client_id', client_secret='your_client_secret')
client = GraphClient(credentials)
# Create a mail assessment request
mail_assessment = MailAssessmentRequest()
mail_assessment.recipient_email = 'user@example.com'
mail_assessment.category = 'spam'
mail_assessment.expected_assessment = 'block'
# Submit the assessment request
client.threat_assessment.requests.add(mail_assessment).execute_query()
# Retrieve assessment results
result = mail_assessment.results
print(f'Assessment status: {mail_assessment.status}')
Best Practices
- Ensure proper authentication with Microsoft Graph API before creating assessment requests
- Verify that the application has the required delegated Mail permissions (Mail.Read or Mail.Read.Shared)
- Always specify a valid recipientEmail that corresponds to the user who received the mail being assessed
- Handle authentication errors and permission issues gracefully
- Check the assessment status before attempting to retrieve results, as processing may be asynchronous
- Follow Microsoft Graph API rate limits and throttling guidelines
- Store and manage credentials securely, never hardcode them in source code
- Use appropriate error handling for network failures and API errors
- Consider implementing retry logic for transient failures
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class ThreatAssessmentRequest 76.0% similar
-
class InformationProtection 67.2% similar
-
class Incident 54.9% similar
-
class Simulation 54.8% similar
-
class Alert_v1 54.6% similar