blob: ea6ae0c5edd0e1e916dde8d4b0ba6f3b3201af49 [file] [log] [blame]
Barry Warsawd2856002004-05-09 18:04:24 +00001# Copyright (C) 2002-2004 Python Software Foundation
2# Author: barry@python.org (Barry Warsaw)
Barry Warsaw2f514a82002-06-01 05:59:12 +00003
4"""Base class for MIME multipart/* type messages.
5"""
6
7from email import MIMEBase
8
9
10
11class MIMEMultipart(MIMEBase.MIMEBase):
12 """Base class for MIME multipart/* type messages."""
13
Barry Warsawd2856002004-05-09 18:04:24 +000014 def __init__(self, _subtype='mixed', boundary=None, _subparts=None,
15 **_params):
Barry Warsaw2f514a82002-06-01 05:59:12 +000016 """Creates a multipart/* type message.
17
18 By default, creates a multipart/mixed message, with proper
Barry Warsawfd2e8f72002-09-30 21:24:00 +000019 Content-Type and MIME-Version headers.
Barry Warsaw2f514a82002-06-01 05:59:12 +000020
21 _subtype is the subtype of the multipart content type, defaulting to
22 `mixed'.
23
24 boundary is the multipart boundary string. By default it is
25 calculated as needed.
26
Barry Warsawfd2e8f72002-09-30 21:24:00 +000027 _subparts is a sequence of initial subparts for the payload. It
Barry Warsawd2856002004-05-09 18:04:24 +000028 must be an iterable object, such as a list. You can always
Barry Warsaw2f514a82002-06-01 05:59:12 +000029 attach new subparts to the message by using the attach() method.
30
Barry Warsawfd2e8f72002-09-30 21:24:00 +000031 Additional parameters for the Content-Type header are taken from the
Barry Warsaw2f514a82002-06-01 05:59:12 +000032 keyword arguments (or passed into the _params argument).
33 """
Barry Warsawbb493a72002-07-09 02:44:26 +000034 MIMEBase.MIMEBase.__init__(self, 'multipart', _subtype, **_params)
35 if _subparts:
Barry Warsawd2856002004-05-09 18:04:24 +000036 for p in _subparts:
37 self.attach(p)
Barry Warsawbb493a72002-07-09 02:44:26 +000038 if boundary:
39 self.set_boundary(boundary)