Skip to content

Commit a61d483

Browse files
authored
Merge pull request #971 from DEV4INO/patch-1
Add copy method to outlook message
2 parents 03e5dac + 600f1a5 commit a61d483

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

office365/outlook/mail/messages/message.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,32 @@ def create_reply_all(self):
176176
self.context.add_query(qry)
177177
return self
178178

179+
def copy(self, destination):
180+
"""
181+
Copy a message to another folder within the specified user's mailbox.
182+
This creates a new copy of the message in the destination folder.
183+
184+
:param str or MailFolder destination: The destination folder ID, or a well-known folder name.
185+
For a list of supported well-known folder names, see mailFolder resource type.
186+
"""
187+
from office365.outlook.mail.folders.folder import MailFolder
188+
189+
def _copy(destination_id):
190+
# type: (str) -> None
191+
payload = {"DestinationId": destination_id}
192+
qry = ServiceOperationQuery(self, "copy", None, payload, None, None)
193+
self.context.add_query(qry)
194+
195+
if isinstance(destination, MailFolder):
196+
197+
def _loaded():
198+
_copy(destination.id)
199+
200+
destination.ensure_property("id", _loaded)
201+
else:
202+
_copy(destination)
203+
return self
204+
179205
def move(self, destination):
180206
"""
181207
Move a message to another folder within the specified user's mailbox.

0 commit comments

Comments
 (0)