From 644d1726d48b8075df5dfc6e1d4a7f128f0105a1 Mon Sep 17 00:00:00 2001 From: DataFactory-Verlingue <86673601+DataFactory-Verlingue@users.noreply.github.com> Date: Wed, 13 Apr 2022 10:01:18 +0200 Subject: [PATCH 1/3] Deal with draft Update to deal with drafts in file tree. --- melusine/connectors/exchange.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/melusine/connectors/exchange.py b/melusine/connectors/exchange.py index d43e8389..4b8c35c0 100644 --- a/melusine/connectors/exchange.py +++ b/melusine/connectors/exchange.py @@ -364,15 +364,28 @@ def _extract_email_attributes(email_item: Message) -> dict: else: attachments_list = [i.name for i in email_item.attachments] - email_dict = { - "message_id": email_item.message_id, - "body": email_item.text_body or "", - "header": email_item.subject or "", - "date": email_item.datetime_sent.isoformat(), - "from": email_item.sender.email_address or None, - "to": to_list, - "attachment": attachments_list, - } + # Modification to deal with draft in arborescence + if email_item.datetime_sent != None and email_item.sender != None: + email_dict = { + "message_id": email_item.message_id, + "body": email_item.text_body or "", + "header": email_item.subject or "", + "date": email_item.datetime_sent.isoformat(), + "from": email_item.sender.email_address or None, + "to": to_list, + "attachment": attachments_list, + } + else: + # There is a draft in the emails + email_dict = { + "message_id": email_item.message_id, + "body": email_item.body or "", + "header": email_item.subject or "", + "date": None, + "from": None, + "to": None, + "attachment": attachments_list, + } return email_dict def route_emails( From 12f368aae0369b4b7d5e42ff50e267f3ba49037d Mon Sep 17 00:00:00 2001 From: DataFactory-Verlingue <86673601+DataFactory-Verlingue@users.noreply.github.com> Date: Wed, 13 Apr 2022 10:23:50 +0200 Subject: [PATCH 2/3] Update exchange.py --- melusine/connectors/exchange.py | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/melusine/connectors/exchange.py b/melusine/connectors/exchange.py index 4b8c35c0..d43e8389 100644 --- a/melusine/connectors/exchange.py +++ b/melusine/connectors/exchange.py @@ -364,28 +364,15 @@ def _extract_email_attributes(email_item: Message) -> dict: else: attachments_list = [i.name for i in email_item.attachments] - # Modification to deal with draft in arborescence - if email_item.datetime_sent != None and email_item.sender != None: - email_dict = { - "message_id": email_item.message_id, - "body": email_item.text_body or "", - "header": email_item.subject or "", - "date": email_item.datetime_sent.isoformat(), - "from": email_item.sender.email_address or None, - "to": to_list, - "attachment": attachments_list, - } - else: - # There is a draft in the emails - email_dict = { - "message_id": email_item.message_id, - "body": email_item.body or "", - "header": email_item.subject or "", - "date": None, - "from": None, - "to": None, - "attachment": attachments_list, - } + email_dict = { + "message_id": email_item.message_id, + "body": email_item.text_body or "", + "header": email_item.subject or "", + "date": email_item.datetime_sent.isoformat(), + "from": email_item.sender.email_address or None, + "to": to_list, + "attachment": attachments_list, + } return email_dict def route_emails( From 8a67dfe08c33390b4905358c381f282a0022001f Mon Sep 17 00:00:00 2001 From: DataFactory-Verlingue <86673601+DataFactory-Verlingue@users.noreply.github.com> Date: Wed, 13 Apr 2022 10:24:04 +0200 Subject: [PATCH 3/3] Update exchange.py --- melusine/connectors/exchange.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/melusine/connectors/exchange.py b/melusine/connectors/exchange.py index d43e8389..331070a9 100644 --- a/melusine/connectors/exchange.py +++ b/melusine/connectors/exchange.py @@ -364,15 +364,28 @@ def _extract_email_attributes(email_item: Message) -> dict: else: attachments_list = [i.name for i in email_item.attachments] - email_dict = { - "message_id": email_item.message_id, - "body": email_item.text_body or "", - "header": email_item.subject or "", - "date": email_item.datetime_sent.isoformat(), - "from": email_item.sender.email_address or None, - "to": to_list, - "attachment": attachments_list, - } + # Modification to deal with draft in file tree + if email_item.datetime_sent != None and email_item.sender != None: + email_dict = { + "message_id": email_item.message_id, + "body": email_item.text_body or "", + "header": email_item.subject or "", + "date": email_item.datetime_sent.isoformat(), + "from": email_item.sender.email_address or None, + "to": to_list, + "attachment": attachments_list, + } + else: + # There is a draft in the emails + email_dict = { + "message_id": email_item.message_id, + "body": email_item.body or "", + "header": email_item.subject or "", + "date": None, + "from": None, + "to": None, + "attachment": attachments_list, + } return email_dict def route_emails(