| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="prev" href="module-MimeWriter.html" /> |
| 13 | <link rel="parent" href="module-MimeWriter.html" /> |
| 14 | <link rel="next" href="module-mimify.html" /> |
| 15 | <meta name='aesop' content='information' /> |
| 16 | <title>12.8.1 MimeWriter Objects </title> |
| 17 | </head> |
| 18 | <body> |
| 19 | <DIV CLASS="navigation"> |
| 20 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 21 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 22 | <tr> |
| 23 | <td class='online-navigation'><a rel="prev" title="12.8 MimeWriter " |
| 24 | href="module-MimeWriter.html"><img src='../icons/previous.png' |
| 25 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 26 | <td class='online-navigation'><a rel="parent" title="12.8 MimeWriter " |
| 27 | href="module-MimeWriter.html"><img src='../icons/up.png' |
| 28 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 29 | <td class='online-navigation'><a rel="next" title="12.9 mimify " |
| 30 | href="module-mimify.html"><img src='../icons/next.png' |
| 31 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 32 | <td align="center" width="100%">Python Library Reference</td> |
| 33 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 34 | href="contents.html"><img src='../icons/contents.png' |
| 35 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 36 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 37 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 38 | <td class='online-navigation'><a rel="index" title="Index" |
| 39 | href="genindex.html"><img src='../icons/index.png' |
| 40 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 41 | </tr></table> |
| 42 | <div class='online-navigation'> |
| 43 | <b class="navlabel">Previous:</b> |
| 44 | <a class="sectref" rel="prev" href="module-MimeWriter.html">12.8 MimeWriter </A> |
| 45 | <b class="navlabel">Up:</b> |
| 46 | <a class="sectref" rel="parent" href="module-MimeWriter.html">12.8 MimeWriter </A> |
| 47 | <b class="navlabel">Next:</b> |
| 48 | <a class="sectref" rel="next" href="module-mimify.html">12.9 mimify </A> |
| 49 | </div> |
| 50 | <hr /></div> |
| 51 | </DIV> |
| 52 | <!--End of Navigation Panel--> |
| 53 | |
| 54 | <H2><A NAME="SECTION0014810000000000000000"></A><A NAME="MimeWriter-objects"></A> |
| 55 | <BR> |
| 56 | 12.8.1 MimeWriter Objects |
| 57 | </H2> |
| 58 | |
| 59 | <P> |
| 60 | <tt class="class">MimeWriter</tt> instances have the following methods: |
| 61 | |
| 62 | <P> |
| 63 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 64 | <td><nobr><b><tt id='l2h-4045' xml:id='l2h-4045' class="method">addheader</tt></b>(</nobr></td> |
| 65 | <td><var>key, value</var><big>[</big><var>, prefix</var><big>]</big><var></var>)</td></tr></table></dt> |
| 66 | <dd> |
| 67 | Add a header line to the MIME message. The <var>key</var> is the name of |
| 68 | the header, where the <var>value</var> obviously provides the value of the |
| 69 | header. The optional argument <var>prefix</var> determines where the header |
| 70 | is inserted; "<tt class="samp">0</tt>" means append at the end, "<tt class="samp">1</tt>" is insert at |
| 71 | the start. The default is to append. |
| 72 | </dl> |
| 73 | |
| 74 | <P> |
| 75 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 76 | <td><nobr><b><tt id='l2h-4046' xml:id='l2h-4046' class="method">flushheaders</tt></b>(</nobr></td> |
| 77 | <td><var></var>)</td></tr></table></dt> |
| 78 | <dd> |
| 79 | Causes all headers accumulated so far to be written out (and |
| 80 | forgotten). This is useful if you don't need a body part at all, |
| 81 | e.g. for a subpart of type <span class="mimetype">message/rfc822</span> that's (mis)used |
| 82 | to store some header-like information. |
| 83 | </dl> |
| 84 | |
| 85 | <P> |
| 86 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 87 | <td><nobr><b><tt id='l2h-4047' xml:id='l2h-4047' class="method">startbody</tt></b>(</nobr></td> |
| 88 | <td><var>ctype</var><big>[</big><var>, plist</var><big>[</big><var>, prefix</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> |
| 89 | <dd> |
| 90 | Returns a file-like object which can be used to write to the |
| 91 | body of the message. The content-type is set to the provided |
| 92 | <var>ctype</var>, and the optional parameter <var>plist</var> provides |
| 93 | additional parameters for the content-type declaration. <var>prefix</var> |
| 94 | functions as in <tt class="method">addheader()</tt> except that the default is to |
| 95 | insert at the start. |
| 96 | </dl> |
| 97 | |
| 98 | <P> |
| 99 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 100 | <td><nobr><b><tt id='l2h-4048' xml:id='l2h-4048' class="method">startmultipartbody</tt></b>(</nobr></td> |
| 101 | <td><var>subtype</var><big>[</big><var>, |
| 102 | boundary</var><big>[</big><var>, plist</var><big>[</big><var>, prefix</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> |
| 103 | <dd> |
| 104 | Returns a file-like object which can be used to write to the |
| 105 | body of the message. Additionally, this method initializes the |
| 106 | multi-part code, where <var>subtype</var> provides the multipart subtype, |
| 107 | <var>boundary</var> may provide a user-defined boundary specification, and |
| 108 | <var>plist</var> provides optional parameters for the subtype. |
| 109 | <var>prefix</var> functions as in <tt class="method">startbody()</tt>. Subparts should be |
| 110 | created using <tt class="method">nextpart()</tt>. |
| 111 | </dl> |
| 112 | |
| 113 | <P> |
| 114 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 115 | <td><nobr><b><tt id='l2h-4049' xml:id='l2h-4049' class="method">nextpart</tt></b>(</nobr></td> |
| 116 | <td><var></var>)</td></tr></table></dt> |
| 117 | <dd> |
| 118 | Returns a new instance of <tt class="class">MimeWriter</tt> which represents an |
| 119 | individual part in a multipart message. This may be used to write the |
| 120 | part as well as used for creating recursively complex multipart |
| 121 | messages. The message must first be initialized with |
| 122 | <tt class="method">startmultipartbody()</tt> before using <tt class="method">nextpart()</tt>. |
| 123 | </dl> |
| 124 | |
| 125 | <P> |
| 126 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 127 | <td><nobr><b><tt id='l2h-4050' xml:id='l2h-4050' class="method">lastpart</tt></b>(</nobr></td> |
| 128 | <td><var></var>)</td></tr></table></dt> |
| 129 | <dd> |
| 130 | This is used to designate the last part of a multipart message, and |
| 131 | should <em>always</em> be used when writing multipart messages. |
| 132 | </dl> |
| 133 | |
| 134 | <DIV CLASS="navigation"> |
| 135 | <div class='online-navigation'> |
| 136 | <p></p><hr /> |
| 137 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 138 | <tr> |
| 139 | <td class='online-navigation'><a rel="prev" title="12.8 MimeWriter " |
| 140 | href="module-MimeWriter.html"><img src='../icons/previous.png' |
| 141 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 142 | <td class='online-navigation'><a rel="parent" title="12.8 MimeWriter " |
| 143 | href="module-MimeWriter.html"><img src='../icons/up.png' |
| 144 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 145 | <td class='online-navigation'><a rel="next" title="12.9 mimify " |
| 146 | href="module-mimify.html"><img src='../icons/next.png' |
| 147 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 148 | <td align="center" width="100%">Python Library Reference</td> |
| 149 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 150 | href="contents.html"><img src='../icons/contents.png' |
| 151 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 152 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 153 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 154 | <td class='online-navigation'><a rel="index" title="Index" |
| 155 | href="genindex.html"><img src='../icons/index.png' |
| 156 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 157 | </tr></table> |
| 158 | <div class='online-navigation'> |
| 159 | <b class="navlabel">Previous:</b> |
| 160 | <a class="sectref" rel="prev" href="module-MimeWriter.html">12.8 MimeWriter </A> |
| 161 | <b class="navlabel">Up:</b> |
| 162 | <a class="sectref" rel="parent" href="module-MimeWriter.html">12.8 MimeWriter </A> |
| 163 | <b class="navlabel">Next:</b> |
| 164 | <a class="sectref" rel="next" href="module-mimify.html">12.9 mimify </A> |
| 165 | </div> |
| 166 | </div> |
| 167 | <hr /> |
| 168 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 169 | </DIV> |
| 170 | <!--End of Navigation Panel--> |
| 171 | <ADDRESS> |
| 172 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 173 | </ADDRESS> |
| 174 | </BODY> |
| 175 | </HTML> |