我们有一些客户使用 Microsoft Outlook 发送附件。但是在 odoo 中,我们只看到winmail.dat文件(而邮件客户端中的一切看起来都很好)。
有什么方法可以强制 odoo 公开winmail.dat内容吗?
我们有一些客户使用 Microsoft Outlook 发送附件。但是在 odoo 中,我们只看到winmail.dat文件(而邮件客户端中的一切看起来都很好)。
有什么方法可以强制 odoo 公开winmail.dat内容吗?
问题在于 Microsoft Outlook 使用传输中性封装格式并将所有附件打包在一个文件中。
有一个很好的用于 tnef 格式的 python 解析器 - 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
您可以在此处找到有关如何执行自定义模块的更多信息。