azure.communication.email package¶
-
class
azure.communication.email.
EmailClient
(endpoint: str, credential: Union[azure.core.credentials.TokenCredential, azure.core.credentials.AzureKeyCredential], **kwargs)[source]¶ A client to interact with the AzureCommunicationService Email gateway.
This client provides operations to send an email and monitor its status.
- Parameters
endpoint (str) – The endpoint url for Azure Communication Service resource.
AzureKeyCredential] credential (Union[TokenCredential,) – The credential we use to authenticate against the service.
- Keyword Arguments
api_version (str) – Azure Communication Email API version. Default value is “2021-10-01-preview”. Note that overriding this default value may result in unsupported behavior.
-
begin_send
(message: Union[collections.abc.MutableMapping[str, Any], IO], **kwargs: Any) → azure.core.polling._poller.LROPoller[collections.abc.MutableMapping[str, Any]][source]¶ Queues an email message to be sent to one or more recipients.
Queues an email message to be sent to one or more recipients.
- Parameters
message (JSON) – Message payload for sending an email. Required.
- Keyword Arguments
continuation_token (str) – A continuation token to restart a poller from a saved state.
- Returns
An instance of LROPoller that returns JSON object
- Return type
LROPoller[JSON]
- Raises
- Example:
# JSON input template you can fill out and use as your body input. message = { "content": { "subject": "str", # Subject of the email message. Required. "html": "str", # Optional. Html version of the email message. "plainText": "str" # Optional. Plain text version of the email message. }, "recipients": { "to": [ { "address": "str", # Email address. Required. "displayName": "str" # Optional. Email display name. } ], "bcc": [ { "address": "str", # Email address. Required. "displayName": "str" # Optional. Email display name. } ], "cc": [ { "address": "str", # Email address. Required. "displayName": "str" # Optional. Email display name. } ] }, "senderAddress": "str", # Sender email address from a verified domain. Required. "attachments": [ { "contentInBase64": "str", # Base64 encoded contents of the attachment. Required. "contentType": "str", # MIME type of the content being attached. Required. "name": "str" # Name of the attachment. Required. } ], "userEngagementTrackingDisabled": bool, # Optional. Indicates whether user engagement tracking should be disabled for this request if the resource-level user engagement tracking setting was already enabled in the control plane. "headers": { "str": "str" # Optional. Custom email headers to be passed. }, "replyTo": [ { "address": "str", # Email address. Required. "displayName": "str" # Optional. Email display name. } ] } # response body for status code(s): 202 response == { "id": "str", # The unique id of the operation. Use a UUID. Required. "status": "str", # Status of operation. Required. Known values are: "NotStarted", "Running", "Succeeded", "Failed", and "Canceled". "error": { "additionalInfo": [ { "info": {}, # Optional. The additional info. "type": "str" # Optional. The additional info type. } ], "code": "str", # Optional. The error code. "details": [ ... ], "message": "str", # Optional. The error message. "target": "str" # Optional. The error target. } }
-
classmethod
from_connection_string
(conn_str: str, **kwargs) → azure.communication.email._email_client.EmailClient[source]¶ Create EmailClient from a Connection String.
- Parameters
conn_str (str) – A connection string to an Azure Communication Service resource.
- Returns
Instance of EmailClient.
- Return type
EmailClient