1 # Copyright (C) 2001,2002 Python Software Foundation
2 # Author: barry@zope.com (Barry Warsaw)
4 """Class representing message/* MIME documents.
7 from email
import Message
8 from email
.MIMENonMultipart
import MIMENonMultipart
12 class MIMEMessage(MIMENonMultipart
):
13 """Class representing message/* MIME documents."""
15 def __init__(self
, _msg
, _subtype
='rfc822'):
16 """Create a message/* type MIME document.
18 _msg is a message object and must be an instance of Message, or a
19 derived class of Message, otherwise a TypeError is raised.
21 Optional _subtype defines the subtype of the contained message. The
22 default is "rfc822" (this is defined by the MIME standard, even though
23 the term "rfc822" is technically outdated by RFC 2822).
25 MIMENonMultipart
.__init
__(self
, 'message', _subtype
)
26 if not isinstance(_msg
, Message
.Message
):
27 raise TypeError, 'Argument is not an instance of Message'
28 # It's convenient to use this base class method. We need to do it
29 # this way or we'll get an exception
30 Message
.Message
.attach(self
, _msg
)
31 # And be sure our default type is set correctly
32 self
.set_default_type('message/rfc822')