aboutsummaryrefslogtreecommitdiffstats
path: root/python/exchange.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/exchange.py')
-rw-r--r--python/exchange.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/python/exchange.py b/python/exchange.py
index fce17e2e..efb36d40 100644
--- a/python/exchange.py
+++ b/python/exchange.py
@@ -1,5 +1,13 @@
-from exchangelib import Credentials, Configuration, Account, DELEGATE, Message
+from exchangelib import (
+ Credentials,
+ Configuration,
+ Account,
+ DELEGATE,
+ Message,
+ FileAttachment,
+)
from pathlib import Path
+from typing import Tuple
import json
@@ -31,7 +39,14 @@ class ExchangeMessage:
for msg in folder.all().order_by("-datetime_sent"):
yield msg
- def send_email(self, subject, body, to_recipients, cc_recipients):
+ def send_email(
+ self,
+ subject,
+ body,
+ to_recipients,
+ cc_recipients,
+ attach: Tuple[FileAttachment] = (),
+ ):
m = Message(
account=self._account,
folder=self._account.sent,
@@ -40,4 +55,6 @@ class ExchangeMessage:
to_recipients=to_recipients,
cc_recipients=cc_recipients,
)
+ for attachment in attach:
+ m.attach(attachment)
m.send_and_save()