# The EmailMessage Class - Google App Engine - Google Code

English ▼
Skip to page content Skip to main navigation
e.g. "templates" or "datastore"

# The EmailMessage Class

An instance of the EmailMessage class represents an email message, and includes a method to send the message using the App Engine Mail service.

`EmailMessage` is provided by the `google.appengine.api.mail` module.

- Introduction
- EmailMessage()
- Instance methods:
  - check_initialized
  - initialize
  - is_initialized
  - send

## Introduction

An EmailMessage instance represents an email message to be sent using the App Engine Mail service. An email message has a set of fields, which can be initialized using the constructor, and adjusted using attributes of the instance.

For a list of the fields of an EmailMessage, see Email Message Fields.

When all of the appropriate fields are set, the send() method sends the email message using the current values of the fields. An EmailMessage instance can be reused to send multiple messages with similar field values.

## Constructor

class EmailMessage(**kw)

  An email message to be sent via the Mail API.

  The fields of the message can be initialized using keyword arguments passed to the constructor. For a list of possible fields, see Email Message Fields.

  Fields can also be set after construction using attributes of the instance, or by passing keyword arguments to the initialize() method.

## Instance Methods

An EmailMessage instance has the following methods:

check_initialized()

  Checks if the EmailMessage is properly initialized for sending. If the message is not properly initialized, the method raises an error that corresponds with the first problem it finds. Returns without raising an error if the message is ready to send.

initialize(**kw)
  Sets fields of the email message using keyword arguments. For a list of possible fields, see Email Message Fields.
is_initialized()
  Returns `True` if the EmailMessage is properly initialized for sending. This performs the same checks as check_initialized(), but does not raise an error.
send()
  Sends the email message.