Email and MIME Modules

email.iterators

Legacy traversal helpers for message trees, including body_line_iterator and typed_subpart_iterator. A MIME message can contain multiple parts of different media types. These iterators select existing payloads and do not fetch external content or decode every payload automatically.

Formal Syntax & Structure

python syntaxpython
import email.iterators

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
from email.message import EmailMessagefrom email.iterators import typed_subpart_iteratormessage = EmailMessage()message.set_content("hello")message.add_alternative("<p>hello</p>", subtype="html")print([part.get_content_subtype() for part in typed_subpart_iterator(message, "text")])
Python Reference