Templates

class dotmailer.templates.Template(**kwargs)

This class represents a DotMailer template. To be able to create a template you will need to define the following required fields:

name The name of the template being created, which needs to be included within the request body.

subject The email subject line of the template, which needs to be included within the request body.

from_name The from name of the template, which needs to be included within the request body.

html_content The HTML content of the template, which needs to be included within the request body.

plain_text_content The plain text content of the template, which needs to be included within the request body.

To access an existing template from your account, you can either obtain a copy of the template by accessing it directly using it’s unique ID value via the get() class method. Alternatively if you don’t know the it’s ID, then use the get_all() to return a list of all the templates that you currently have defined within your account.

create()

Create a new DotMailer template.

This function will issue the create request to DotMailer’s API, passing through all the information you have defined.

classmethod get_all()

Attempt to get a list of all the templates that you have associated with your account.

This function continues to request for more templates until the server doesn’t return any more templates.

Returns:A list containing Template objects that represents all the templates that are associated with your account
classmethod get_by_id(id)

Attempt to get a specific template from DotMailer by it’s ID value.

If the ID specified can not be found/is not associated with your account then dotmailer.exceptions.ErrorTemplateNotFound will be raised.

Parameters:id – The ID of the template.
Returns:A Template instance, which represents the DotMailer template.
update()

Updates the template