Merge lp:~openerp-dev/openobject-addons/7.0-inline-images-in-mail into lp:openobject-addons/7.0

Proposed by Paramjit Singh Sahota(OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-inline-images-in-mail
Merge into: lp:openobject-addons/7.0
Diff against target: 27 lines (+10/-0)
1 file modified
mail/mail_thread.py (+10/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-inline-images-in-mail
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+206433@code.launchpad.net

Description of the change

Hello,

Fixed the issue of mail where the image is not visible on mail wall if the images coming in email as inline image.
Related branch of server: https://code.launchpad.net/~openerp-dev/openobject-server/7.0-inline-images-in-mail

Thankz You.

To post a comment you must log in.
9841. By Paramjit Singh Sahota(OpenERP)

[IMP] Improved code.

Unmerged revisions

9841. By Paramjit Singh Sahota(OpenERP)

[IMP] Improved code.

9840. By Paramjit Singh Sahota(OpenERP)

[FIX] Fixed the issue of email in which the images coming inline in email are not visible.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'mail/mail_thread.py'
--- mail/mail_thread.py 2014-02-13 09:57:17 +0000
+++ mail/mail_thread.py 2014-02-18 08:50:43 +0000
@@ -29,6 +29,7 @@
29import time29import time
30import xmlrpclib30import xmlrpclib
31from email.message import Message31from email.message import Message
32from lxml import etree
3233
33from openerp import tools34from openerp import tools
34from openerp import SUPERUSER_ID35from openerp import SUPERUSER_ID
@@ -801,6 +802,15 @@
801 else:802 else:
802 filename=decode(filename)803 filename=decode(filename)
803 encoding = part.get_content_charset() # None if attachment804 encoding = part.get_content_charset() # None if attachment
805 # For inline attachement
806 content_type = re.split(r"\s*[,;]\s*", part.get('Content-Type').strip())
807 if part.get('content-disposition', '').strip().startswith('inline') or content_type[0] == 'image/png':
808 content_id = str(part.get('Content-ID'))
809 content_id = email.utils.collapse_rfc2231_value(content_id).strip()
810 doc = etree.HTML(str(body))
811 for node in doc.xpath("//img[@src='cid:%s']" %(content_id)):
812 node.set('src', 'data:%s;%s,%s' %(content_type[0], part.get('Content-Transfer-Encoding'), part.get_payload()))
813 body = etree.tostring(doc)
804 # 1) Explicit Attachments -> attachments814 # 1) Explicit Attachments -> attachments
805 if filename or part.get('content-disposition', '').strip().startswith('attachment'):815 if filename or part.get('content-disposition', '').strip().startswith('attachment'):
806 attachments.append((filename or 'attachment', part.get_payload(decode=True)))816 attachments.append((filename or 'attachment', part.get_payload(decode=True)))