email.message.MIMEPart

class email.message.MIMEPart(policy=default) This class represents a subpart of a MIME message. It is identical to EmailMessage, except that no MIME-Version headers are added when set_content() is called, since sub-parts do not need their own MIME-Version headers.

email.message.Message.__str__()

__str__() Equivalent to as_string(). Allows str(msg) to produce a string containing the formatted message.

email.message.Message.__setitem__()

__setitem__(name, val) Add a header to the message with field name name and value val. The field is appended to the end of the message’s existing fields. Note that this does not overwrite or delete any existing header with the same name. If you want to ensure that the new header is the only one present in the message with field name name, delete the field first, e.g.: del msg['subject'] msg['subject'] = 'Python roolz!'

email.message.Message.__len__()

__len__() Return the total number of headers, including duplicates.

email.message.Message.__getitem__()

__getitem__(name) Return the value of the named header field. name should not include the colon field separator. If the header is missing, None is returned; a KeyError is never raised. Note that if the named field appears more than once in the message’s headers, exactly which of those field values will be returned is undefined. Use the get_all() method to get the values of all the extant named headers.

email.message.Message.__delitem__()

__delitem__(name) Delete all occurrences of the field with name name from the message’s headers. No exception is raised if the named field isn’t present in the headers.

email.message.Message.__contains__()

__contains__(name) Return true if the message object has a field named name. Matching is done case-insensitively and name should not include the trailing colon. Used for the in operator, e.g.: if 'message-id' in myMessage: print('Message-ID:', myMessage['message-id'])

email.message.Message.__bytes__()

__bytes__() Equivalent to as_bytes(). Allows bytes(msg) to produce a bytes object containing the formatted message. New in version 3.4.

email.message.Message.walk()

walk() The walk() method is an all-purpose generator which can be used to iterate over all the parts and subparts of a message object tree, in depth-first traversal order. You will typically use walk() as the iterator in a for loop; each iteration returns the next subpart. Here’s an example that prints the MIME type of every part of a multipart message structure: >>> for part in msg.walk(): ... print(part.get_content_type()) multipart/report text/plain message/delivery-status te

email.message.Message.values()

values() Return a list of all the message’s field values.