Skip to content

Commit

Permalink
Update Exchange.py (#1179)
Browse files Browse the repository at this point in the history
* Update Exchange.py

Added the functions forward_message and delete_message. Has been in production at nexler for a while now.


---------

Co-authored-by: Mika Hänninen <[email protected]>
  • Loading branch information
ThomasMellema and mikahanninen authored Apr 5, 2024
1 parent 6f64d6e commit e95f447
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/main/src/RPA/Email/Exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,3 +1127,23 @@ def save_message(self, message: dict, filename: str):
raise ValueError("Filename extension needs to be '.eml'")
with open(absolute_filepath, "wb") as message_out:
message_out.write(message["mime_content"])

def forward_message(self, message: Dict, recipients: Union[str, List]):
"""Forward message.
:param message: dictionary containing message details
:param recipients: email address or list of email addresses
"""
recipients = recipients if isinstance(recipients, list) else [recipients]
# pylint: disable=no-member
m = self.account.sent.get(id=message["id"], changekey=message["changekey"])
m.forward(to_recipients=recipients, subject=message["subject"], body=None)

def delete_message(self, message: Dict):
"""Delete message.
:param message: dictionary containing message details
"""
# pylint: disable=no-member
m = self.account.sent.get(id=message["id"], changekey=message["changekey"])
m.move(to_folder=self.account.trash)

0 comments on commit e95f447

Please sign in to comment.