PyDocs

Nav

Internet Data Handling

EmailMessage

  • EmailMessage(policy=default)
If policy is specified use the rules it specifies to update and serialize the representation of the message. If policy is not set, use the default policy, which follows the rules of the email RFCs except for line endings (instead of the RFC mandated \r\n, it uses the Python standard \n line endings). For more information see the policy documentation. [2]
Members of EmailMessage

_

__bytes__
Return the entire formatted message as a bytes object.
__contains__
Return True if the message object has a field named name.
__delitem__
Delete all occurrences of a header, if present.
__getitem__
Get a header value.
__len__
Return the total number of headers, including duplicates.
__setitem__
Set the value of a header.
__str__
Return the entire formatted message as a string.

a

add_alternative
If the message is a multipart/alternative, create a new message object, pass all of the arguments to its set_content() method, and attach() it to the multipart.
add_attachment
If the message is a multipart/mixed, create a new message object, pass all of the arguments to its set_content() method, and attach() it to the multipart.
add_header
Extended header setting.
add_related
If the message is a multipart/related, create a new message object, pass all of the arguments to its set_content() method, and attach() it to the multipart.
as_bytes
Return the entire formatted message as a bytes object.
as_string
Return the entire formatted message as a string.

c

clear
Remove the payload and all of the headers.
clear_content
Remove the payload and all of the !Content- headers, leaving all other headers intact and in their original order.

d

defects
The defects attribute contains a list of all the problems found when parsing this message.
del_param
Remove the given parameter completely from the Content-Type header.

e

epilogue
The epilogue attribute acts the same way as the preamble attribute, except that it contains text that appears between the last boundary and the end of the message.

g

get
Get a header value.
get_all
Return a list of all the values for the named field.
get_body
Return best candidate mime part for display as 'body' of message.
get_boundary
Return the boundary associated with the payload if present.
get_charsets
Return a list containing the charset(s) used in this message.
get_content
Call the get_content() method of the content_manager, passing self as the message object, and passing along any other arguments or keywords as additional arguments.
get_content_charset
Return the charset parameter of the Content-Type header.
get_content_disposition
Return the message's content-disposition if it exists, or None.
get_content_maintype
Return the message's main content type.
get_content_subtype
Returns the message's sub-content type.
get_content_type
Return the message's content type.
get_default_type
Return the 'default' content type.
get_filename
Return the filename associated with the payload if present.
get_unixfrom
Return the message’s envelope header.

i

is_attachment
Return True if there is a Content-Disposition header and its (case insensitive) value is attachment, False otherwise.
is_multipart
Return True if the message consists of multiple parts.
items
Get all the message's header fields and values.
iter_attachments
Return an iterator over the non-main parts of a multipart.
iter_parts
Return an iterator over all immediate subparts of a multipart.

k

keys
Return a list of all the message's header field names.

m

make_alternative
Convert a non-multipart or a multipart/related into a multipart/alternative, moving any existing Content- headers and payload into a (new) first part of the multipart.
make_mixed
Convert a non-multipart, a multipart/related, or a multipart-alternative into a multipart/mixed, moving any existing Content- headers and payload into a (new) first part of the multipart.
make_related
Convert a non-multipart message into a multipart/related message, moving any existing Content- headers and payload into a (new) first part of the multipart.

p

preamble
The format of a MIME document allows for some text between the blank line following the headers, and the first multipart boundary string.

r

replace_header
Replace a header.

s

set_boundary
Set the boundary parameter in Content-Type to 'boundary'.
set_content
Call the set_content() method of the content_manager, passing self as the message object, and passing along any other arguments or keywords as additional arguments.
set_default_type
Set the 'default' content type.
set_param
Set a parameter in the Content-Type header.
set_unixfrom
Set the message’s envelope header to unixfrom, which should be a string.

v

values
Return a list of all the message's header values.

w

walk
Walk over the message tree, yielding each subpart.
0 Examples
No examples for email.message/EmailMessage.
See Also
No see-alsos for email.message/EmailMessage
0 Notes
No notes for EmailMessage