From d091a16002c07cbc694c4df3295a2807175f94e3 Mon Sep 17 00:00:00 2001 From: Bruno Tikami Date: Mon, 15 Feb 2016 16:16:28 -0200 Subject: [PATCH] UPDATED: when creating new Ticket instances from email messages, also save their "Message-Id" field. --- helpdesk/management/commands/get_email.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index e6a3b124..7233a3f8 100644 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -170,8 +170,10 @@ def decode_mail_headers(string): def ticket_from_message(message, queue, quiet): # 'message' must be an RFC822 formatted message. + msg = message message = email.message_from_string(msg) + subject = message.get('subject', _('Created from e-mail')) subject = decode_mail_headers(decodeUnknown(message.get_charset(), subject)) subject = subject.replace("Re: ", "").replace("Fw: ", "").replace("RE: ", "").replace("FW: ", "").replace("Automatic reply: ", "").strip() @@ -258,11 +260,12 @@ def ticket_from_message(message, queue, quiet): if smtp_priority in high_priority_types or smtp_importance in high_priority_types: priority = 2 - if ticket == None: + if ticket is None: t = Ticket( title=subject, queue=queue, submitter_email=sender_email, + submitter_email_id=message.get('message-id'), created=now, description=body, priority=priority,