Odoo:如何处理对话中附加的 winmail.dat?

Odoo: How to process winmail.dat attached in conversations?

我们有一些客户使用 Microsoft Outlook 发送附件。但是在 odoo 中我们只能看到 winmail.dat 个文件(而在邮件客户端中一切看起来都正常)。

有没有办法强制 odoo 公开 winmail.dat 内容?

问题是 Microsoft Outlook 使用 Transport Neutral Encapsulation Format 并将所有附件打包在一个文件中。

有一个很好的 python tnef 格式解析器 - tnefparse。我建议您使用它并编写简单的模块来扩展 mail.thread 模型,像这样

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

您可以找到有关如何创建自定义模块的更多信息here