seprate attachment from mail

bzr revid: mga@tinyerp.com-e2964d02a5340c4ffebb002364b8cbfd7a41c480
This commit is contained in:
Mantavya Gajjar 2007-04-02 10:14:28 +00:00
parent 257da7d41e
commit 39e74f492f
1 changed files with 9 additions and 6 deletions

View File

@ -90,13 +90,16 @@ class email_parser(object):
body = ''
if msg.is_multipart():
for part in msg.get_payload():
if(part.get_content_maintype()=='application'):
if part.get_content_maintype()=='application' or part.get_content_maintype()=='image':
filename = part.get_filename();
#fp = open(os.path.join('/home/admin/Desktop/', filename), 'wb')
fp.write(part.get_payload(decode=1))
#fp.close()
elif (part.get_content_maintype()=='text') and (part.get_content_subtype()=='plain'):
body += part.get_payload(decode=1).decode(part.get_charsets()[0])
# #fp = open(os.path.join('/home/admin/test-src/', filename), 'wb')
# #fp.write(part.get_payload(decode=1))
# #fp.close()
#TODO : make any array of the attachment and return back to called function so that
# from that function we can store it in to Tiny
elif(part.get_content_maintype()=='text') and (part.get_content_subtype()=='plain'):
body += part.get_payload(decode=1); #.decode(part.get_charsets()[0])
#end if
#end for
else: