internet data handling and encoding of the returned list are tuples (namevaluewhere name is the parameter name and value is the value as returned by the get_param(method get_payload([ [decode]]returns the payload of message if the message is simple messagea byte string containing the message body is returned if the message is multipart messagea list containing all the subparts is returned for multipart messagesi specifies an optional index in this list if suppliedonly that message component will be returned if decode is truethe payload is decoded according to the setting of any 'content-transfer-encodingheader that might be present (for example'quoted-printable''base 'and so onto decode the payload of simple nonmultipart messageset to none and decode to true or specify decode using keyword argument it should be emphasized that the payload is returned as byte string containing the raw content if the payload represents text encoded in utf- or some other encodingyou will need to use the decode(method on the result to convert it get_unixfrom(returns the unix-style 'from lineif any is_multipart(returns true if is multipart message walk(creates generator that iterates over all the subparts of messageeach of which is also represented by message instance the iteration is depth-first traversal of the message typicallythis function could be used to process all the components of multipart message finallymessage instances have few attributes that are related to low-level parsing process preamble any text that appears in multipart message between the blank line that signals the end of the headers and the first occurrence of the multipart boundary string that marks the first subpart of the message epilogue any text in the message that appears after the last multipart boundary string and the end of the message defects list of all message defects found when parsing the message consult the online documentation for the email errors module for further details the following example illustrates how the message class is used while parsing an email message the following code reads an email messageprints short summary of useful headersprints the plain text portions of the messageand saves any attachments import email import sys open(sys argv[ ]," " email message_from_file(fopen message file parse message lib fl ff