D
Davor Cengija
I need to write a script which should extract the attachment from a text
file, which is saved as MIME mail message. Unfortunatelly,
Message.is_multipart() returns False so msg.get_payload() returns the
complete message. What I need is the attachment only. Is it possible to do
that with standard email package without the actual string level parsing?
This is how my file/message looks like:
====== start here ========
This is a multi-part message in MIME format.
------=_NextPart_000_0026_01C3B347.DBEA9660
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
CONTENT
signature, etc
------=_NextPart_000_0026_01C3B347.DBEA9660
Content-Type: application/octet-stream;
name="filename.csv"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="filename.csv"
10012;20031118;292.67;4
101;23;19.98;2;39.96
102;24;21.89;4;87.56
------=_NextPart_000_0026_01C3B347.DBEA9660--
====== end here ========
So, I obviously need this part only:
10012;20031118;292.67;4
101;23;19.98;2;39.96
102;24;21.89;4;87.56
Python 2.3.2 on windows.
Thanks and regards,
Davor
file, which is saved as MIME mail message. Unfortunatelly,
Message.is_multipart() returns False so msg.get_payload() returns the
complete message. What I need is the attachment only. Is it possible to do
that with standard email package without the actual string level parsing?
This is how my file/message looks like:
====== start here ========
This is a multi-part message in MIME format.
------=_NextPart_000_0026_01C3B347.DBEA9660
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
CONTENT
signature, etc
------=_NextPart_000_0026_01C3B347.DBEA9660
Content-Type: application/octet-stream;
name="filename.csv"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="filename.csv"
10012;20031118;292.67;4
101;23;19.98;2;39.96
102;24;21.89;4;87.56
------=_NextPart_000_0026_01C3B347.DBEA9660--
====== end here ========
So, I obviously need this part only:
10012;20031118;292.67;4
101;23;19.98;2;39.96
102;24;21.89;4;87.56
Python 2.3.2 on windows.
Thanks and regards,
Davor