# SendGrid Tasks


Tasks for interacting with SendGrid.

# SendEmail

class

prefect.tasks.sendgrid.sendgrid.SendEmail

(from_email="notifications@prefect.io", to_emails=None, subject=None, html_content=None, category=None, attachment_file_path=None, sendgrid_api_key=None, **kwargs)[source]

A task for sending an email via Twilio SendGrid.

Args:

  • from_email (str): The email address of the sender; defaults to notifications@prefect.io
  • to_emails (Union[str, Tuple[str, str], List[str], List[Tuple[str, str]]]): The email address of the recipient(s); can also be provided at runtime. Refer to SendGrid-Python for specifics.
  • subject (str, optional): The subject of the email; can also be provided at runtime
  • html_content (str): The html body of the email; can also be provided at runtime
  • category (Union[str, List[str]], optional): The category/categories to use for the email; can also be provided at runtime
  • attachment_file_path (Union[str, Path], optional): The file path of the email attachment; can also be provided at runtime
  • sendgrid_api_key (str): The SendGrid API key used for authentication; can also be provided at runtime, which is preferred since a secret can be used
  • **kwargs (optional): additional kwargs to pass to the Task constructor

methods:                                                                                                                                                       

prefect.tasks.sendgrid.sendgrid.SendEmail.run

(from_email="notifications@prefect.io", to_emails=None, subject=None, html_content=None, category=None, attachment_file_path=None, sendgrid_api_key=None)[source]

Run message which sends an email via SendGrid.

Args:

  • from_email (str): The email address of the sender; defaults to the one provided at initialization
  • to_emails (Union[str, Tuple[str, str], List[str], List[Tuple[str, str]]]): The email address of the recipient(s); defaults to the one provided at initialization. Refer to SendGrid-Python for specifics.
  • subject (str, optional): The subject of the email; defaults to the one provided at initialization
  • html_content (str): The html body of the email; defaults to the one provided at initialization
  • category (Union[str, List[str]], optional): The category/categories to use for the email; defaults to those provided at initialization
  • attachment_file_path (Union[str, Path], optional): The file path of the email attachment; defaults to the one provided at initialization
  • sendgrid_api_key (str, optional): The SendGrid API key used for authentication; if not provided here, will use the value provided at initialization
Raises:
  • ValueError: if no API key is provided
Returns:
  • python_http_client.client.Response: A Python-HTTP-Client object indicating the status of the response



This documentation was auto-generated from commit bd9182e
on July 31, 2024 at 18:02 UTC