[EMAIL PROTECTED] wrote:
> I figured out how to save an e-mail message as a text file, but I'm
> not sure how to decode the encoded part as I am not sure how much I
> need to include to decode it properly.  Here is what a message looks
> like:
>
>
> Received: from INGESTOR2SQA ([10.220.83.198]) by sqaserver300 with
> Microsoft SMTPSVC(6.0.3790.0);
>        Thu, 31 Jul 2008 12:10:26 -0700
> mime-version: 1.0
> from: "AVDN Ingestor" <[EMAIL PROTECTED]>
> to: [EMAIL PROTECTED]
> date: 31 Jul 2008 17:53:40 +0000
> subject: Upload Status for test
> content-type: multipart/mixed; boundary=--boundary_2_09ab8836-
> ff06-41a6-94d6-59258539bf88
> Return-Path: [EMAIL PROTECTED]
> Message-ID: <[EMAIL PROTECTED]>
> X-OriginalArrivalTime: 31 Jul 2008 19:10:26.0125 (UTC)
> FILETIME=[16D08FD0:01C8F341]
>
>
> ----boundary_2_09ab8836-ff06-41a6-94d6-59258539bf88
> content-type: text/plain; charset=us-ascii
> content-transfer-encoding: quoted-printable
>
> For additional information, please see attachment.
> ----boundary_2_09ab8836-ff06-41a6-94d6-59258539bf88
> content-type: text/xml; name=status.xml; charset=utf-8
> content-transfer-encoding: base64
> content-disposition: attachment
>
> PGF2ZG5fcG5tIHZlcnNpb249IjEuMSIgc2VuZGVyPSJhdmRud2VzdGRjMSIgZG9jbnVtYmVy
> PSJvaHV0bHBxeXptM25xd3lrYm9wd3pwdTUiIHN0YXR1cz0ic3VjY2Vzc2Z1bCI
> +PGNvbnRh
> Y3QgcGhvbmU9IjQwOC05MzEtOTIzMiIgZW1haWw9Im0uY2hhbkBhdm5ldHdvcmtzLmNvbSIg
> Lz48YXNzZXRzdGF0ZSBwcm92aWRlcmlkPSJTUUEiIGFzc2V0aWQ9ImFjZjFlM2Q2ZWJjZjcw
> NDcwNWFjIiBmaWxlbmFtZT0iXHZpZGVvXGZvb1xib3VnZTAwMy4zMjBfMjQwX250c2NfYWMz
> XzAxLmpwZyIgbm90aWZpY2F0aW9uPSIxMjAiIC8+PGFzc2V0c3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y4zMjBfMjQwX250c2Nf
> YWMzXzA3LmpwZyIgbm90aWZpY2F0aW9uPSIxMjAiIC8+PGFzc2V0c3RhdGUgcHJvdmlkZXJp
> ZD0iU1FBIiBhc3NldGlkPSJhY2YxZTNkNmViY2Y3MDQ3MDVhYyIgZmlsZW5hbWU9Ilx2aWRl
> b1xmb29cYm91Z2UwMDMuMzIwXzI0MF9udHNjX2FjM18wNi5qcGciIG5vdGlmaWNhdGlvbj0i
> MTIwIiAvPjxhc3NldHN0YXRlIHByb3ZpZGVyaWQ9IlNRQSIgYXNzZXRpZD0iYWNmMWUzZDZl
> YmNmNzA0NzA1YWMiIGZpbGVuYW1lPSJcdmlkZW9cZm9vXGJvdWdlMDAzLjMyMF8yNDBfbnRz
> Y19hYzNfMDUuanBnIiBub3RpZmljYXRpb249IjEyMCIgLz48YXNzZXRzdGF0ZSBwcm92aWRl
> cmlkPSJTUUEiIGFzc2V0aWQ9ImFjZjFlM2Q2ZWJjZjcwNDcwNWFjIiBmaWxlbmFtZT0iXHZp
> ZGVvXGZvb1xib3VnZTAwMy4zMjBfMjQwX250c2NfYWMzXzA5LmpwZyIgbm90aWZpY2F0aW9u
> PSIxMjAiIC8+PGFzc2V0c3RhdGUgcHJvdmlkZXJpZD0iU1FBIiBhc3NldGlkPSJhY2YxZTNk
> NmViY2Y3MDQ3MDVhYyIgZmlsZW5hbWU9Ilx2aWRlb1xmb29cYm91Z2UwMDMuMzIwXzI0MF9u
> dHNjX2FjMy50cyIgbm90aWZpY2F0aW9uPSIxMjAiIC8+PC9hdmRuX3BubT4=
> ----boundary_2_09ab8836-ff06-41a6-94d6-59258539bf88--
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>   
You need to get the content type ('content-type: text/xml;' from email
headers above) using the email library method 'get_content_type'. Then
get filename using the get_filename method. This will help you decide
what to do with the attachment and how to save it (see [1] for help on
email library). Then use base64 library to decode the attachment (see [2])
 
[1] http://docs.python.org/lib/module-email.html
[2] http://www.python.org/doc/2.3/lib/module-base64.html

HTH

Regards

Nicolaas

-- 

The three things to remember about Llamas:
1) They are harmless
2) They are deadly
3) They are made of lava, and thus nice to cuddle. 


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to