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