On this page
mailbox.MHMessage
Prev: mailbox.MH | Up: mailbox | Next: mailbox.MMDF
Rel: mailbox.Babyl, mailbox.BabylMessage, mailbox.Error, mailbox.ExternalClashError
Ref: docs.python.org — mailbox.MHMessage
Tags: #public #python3 #stdlib #mailbox
Import
import mailbox
from mailbox import MHMessage
Signature & Overview
mailbox.MHMessage(message=None)
Message with MH-specific properties.
Methods & Attributes
MHMessage.add_header(self, _name, _value, **_params)— Extended header setting.MHMessage.add_sequence(self, sequence)— Add sequence to list of sequences including the message.MHMessage.as_bytes(self, unixfrom=False, policy=None)— Return the entire formatted message as a bytes object.MHMessage.as_string(self, unixfrom=False, maxheaderlen=0, policy=None)— Return the entire formatted message as a string.MHMessage.attach(self, payload)— Add the given payload to the current payload.MHMessage.del_param(self, param, header='content-type', requote=True)— Remove the given parameter completely from the Content-Type header.MHMessage.get(self, name, failobj=None)— Get a header value.MHMessage.get_all(self, name, failobj=None)— Return a list of all the values for the named field.MHMessage.get_boundary(self, failobj=None)— Return the boundary associated with the payload if present.MHMessage.get_charset(self)— Return the Charset instance associated with the message's payload.MHMessage.get_charsets(self, failobj=None)— Return a list containing the charset(s) used in this message.MHMessage.get_content_charset(self, failobj=None)— Return the charset parameter of the Content-Type header.MHMessage.get_content_disposition(self)— Return the message's content-disposition if it exists, or None.MHMessage.get_content_maintype(self)— Return the message's main content type.MHMessage.get_content_subtype(self)— Returns the message's sub-content type.MHMessage.get_content_type(self)— Return the message's content type.MHMessage.get_default_type(self)— Return the 'default' content type.MHMessage.get_filename(self, failobj=None)— Return the filename associated with the payload if present.MHMessage.get_param(self, param, failobj=None, header='content-type', unquote=True)— Return the parameter value if found in the Content-Type header.MHMessage.get_params(self, failobj=None, header='content-type', unquote=True)— Return the message's Content-Type parameters, as a list.MHMessage.get_payload(self, i=None, decode=False)— Return a reference to the payload.MHMessage.get_sequences(self)— Return a list of sequences that include the message.MHMessage.get_unixfrom(self)—MHMessage.get_unixfrommethod/property.MHMessage.is_multipart(self)— Return True if the message consists of multiple parts.MHMessage.items(self)— Get all the message's header fields and values.MHMessage.keys(self)— Return a list of all the message's header field names.MHMessage.raw_items(self)— Return the (name, value) header pairs without modification.MHMessage.remove_sequence(self, sequence)— Remove sequence from the list of sequences including the message.MHMessage.replace_header(self, _name, _value)— Replace a header.MHMessage.set_boundary(self, boundary)— Set the boundary parameter in Content-Type to 'boundary'.MHMessage.set_charset(self, charset)— Set the charset of the payload to a given character set.MHMessage.set_default_type(self, ctype)— Set the 'default' content type.MHMessage.set_param(self, param, value, header='Content-Type', requote=True, charset=None, language='', replace=False)— Set a parameter in the Content-Type header.MHMessage.set_payload(self, payload, charset=None)— Set the payload to the given value.MHMessage.set_raw(self, name, value)— Store name and value in the model without modification.MHMessage.set_sequences(self, sequences)— Set the list of sequences that include the message.MHMessage.set_type(self, type, header='Content-Type', requote=True)— Set the main type and subtype for the Content-Type header.MHMessage.set_unixfrom(self, unixfrom)—MHMessage.set_unixfrommethod/property.MHMessage.values(self)— Return a list of all the message's header values.MHMessage.walk(self)— Walk over the message tree, yielding each subpart.
Usage
import mailbox
msg = mailbox.MHMessage()
msg.add_sequence("unseen")
assert "unseen" in msg.get_sequences()
Gotchas
- Message subclass for
MHmailboxes.
REPL Inspect
from mailbox import MHMessage
help(MHMessage)
Linked from
Related notes
- tuts/python3/stdlib_module/mailbox/MH Linked here; links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/MMDF Linked here; links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/Babyl Linked here; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/BabylMessage Linked here; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/Error Linked here; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/ExternalClashError Linked here; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/Mailbox Linked here; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/mailbox/FormatError shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/Maildir shared tags: #mailbox, #stdlib