Email message python Grabbing parts of a message
===

Ok so I am using the imap lib to download a message. I do not want to download the entire message only look at the attachment. Like for example when the message is recieved and downloaded as a whole the following .txt attachment is shown:


        ------=_Part_1476882_26131288.1342315902872--\r\n\r\n------
    =_Part_1476883_28164997.1342315902872\r\nContent-Type: application/octet-stream; 
    name=textplain_2.txt\r\nContent-Transfer-Encoding: 7bit\r\nContent-Disposition: attachment;
     filename=textplain_2.txt\r\n\r\nBhh\r\n------=_Part_1476883_28164997.1342315902872--\r\n\r\n'


The Bhh in the above message was the content of the text file. Is there some way to JUST download the attachment? I saw a tutorial on http://www.devshed.com/c/a/Python/Python-Email-Libraries-part-2-IMAP/3/ which was talking about this but I wasn't sure how to download or get just the contents of the attached text file...

They suggested to do something like....

  

     r, data = server.fetch(‘6’, ‘(UID BODY[TEXT])’)

      r, data = server.fetch(‘6’, ‘(UID ENVELOPE)’)

      r, data = server.fetch(‘2:5’, ‘(BODY[HEADER.FIELDS (SUBJECT FROM)])

I was thinking it would be something along the lines of:

     server.fetch(‘6’, ‘(UID BODY[ATTACHMENT???<-------])’)
Please help!