convert all message in to the text message
authorMantavya Gajjar <mga@tinyerp.com>
Tue, 24 Mar 2009 13:46:24 +0000 (19:16 +0530)
committerMantavya Gajjar <mga@tinyerp.com>
Tue, 24 Mar 2009 13:46:24 +0000 (19:16 +0530)
html->text

bzr revid: mga@tinyerp.com-20090324134624-6iw3hymesqvlkmi8

addons/crm/scripts/openerp-mailgate/openerp-mailgate.py

index bf4f6c7..0380770 100644 (file)
@@ -141,7 +141,9 @@ class email_parser(object):
         message['attachment'] = {};
         attachment = message['attachment'];
         counter = 1;
-
+        def replace(match):
+            return ''
+            
         for part in msg.walk():
             if part.get_content_maintype() == 'multipart':
                 continue
@@ -149,7 +151,10 @@ class email_parser(object):
             if part.get_content_maintype()=='text' and part.get_content_subtype() == 'plain':
                 buf = part.get_payload(decode=True)
                 if buf:
-                    message['body'] += buf.decode(part.get_charsets()[0] or 'ascii', 'replace')
+                    txt = buf.decode(part.get_charsets()[0] or 'ascii', 'replace')
+                    txt = re.sub("<(\w)>", replace, txt)
+                    txt = re.sub("<\/(\w)>", replace, txt)
+                    message['body'] += txt
             elif part.get_content_maintype()=='application' or part.get_content_maintype()=='image' or part.get_content_maintype()=='text':
                 filename = part.get_filename();
                 if filename :