We have some customers who uses Microsoft Outlook to send attachments. However in odoo we see only winmail.dat
files (while everything looks ok in mail client).
Is there any way to force odoo to expose winmail.dat
content?
The problem is that Microsoft Outlook uses Transport Neutral Encapsulation Format and packs all attachments in one file.
There is a good python parser for tnef format - tnefparse
. I'd suggest you to use it and write simple module to extend mail.thread
model like this
from tnefparse import TNEF
from openerp.osv import osv
class MailThread(osv.Model):
_inherit = 'mail.thread'
def _message_extract_payload(self, message, save_original=False):
body, attachments = \
super(MailThread, self)\
._message_extract_payload(message, save_original=save_original)
new_attachments = []
for name, content in attachments:
new_attachments.append((name, content))
if name and name.strip().lower() in ['winmail.dat', 'win.dat']:
try:
winmail = TNEF(content)
for attach in winmail.attachments:
new_attachments.append((attach.name, attach.data))
except:
# some processing here
pass
return body, new_attachments
You can find more information on how to do custom modules here.