Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#136] Deal with draft in file tree #137

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions melusine/connectors/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down