jpayne@68: # Copyright (C) 2001-2006 Python Software Foundation jpayne@68: # Author: Barry Warsaw jpayne@68: # Contact: email-sig@python.org jpayne@68: jpayne@68: """Class representing message/* MIME documents.""" jpayne@68: jpayne@68: __all__ = ['MIMEMessage'] jpayne@68: jpayne@68: from email import message jpayne@68: from email.mime.nonmultipart import MIMENonMultipart jpayne@68: jpayne@68: jpayne@68: jpayne@68: class MIMEMessage(MIMENonMultipart): jpayne@68: """Class representing message/* MIME documents.""" jpayne@68: jpayne@68: def __init__(self, _msg, _subtype='rfc822', *, policy=None): jpayne@68: """Create a message/* type MIME document. jpayne@68: jpayne@68: _msg is a message object and must be an instance of Message, or a jpayne@68: derived class of Message, otherwise a TypeError is raised. jpayne@68: jpayne@68: Optional _subtype defines the subtype of the contained message. The jpayne@68: default is "rfc822" (this is defined by the MIME standard, even though jpayne@68: the term "rfc822" is technically outdated by RFC 2822). jpayne@68: """ jpayne@68: MIMENonMultipart.__init__(self, 'message', _subtype, policy=policy) jpayne@68: if not isinstance(_msg, message.Message): jpayne@68: raise TypeError('Argument is not an instance of Message') jpayne@68: # It's convenient to use this base class method. We need to do it jpayne@68: # this way or we'll get an exception jpayne@68: message.Message.attach(self, _msg) jpayne@68: # And be sure our default type is set correctly jpayne@68: self.set_default_type('message/rfc822')