MCPcopy Create free account
hub / github.com/O365/python-o365 / send

Method send

O365/message.py:724–759  ·  view source on GitHub ↗

Sends this message :param bool save_to_sent_folder: whether or not to save it to sent folder :return: Success / Failure :rtype: bool

(self, save_to_sent_folder=True)

Source from the content-addressed store, hash-verified

722 return message
723
724 def send(self, save_to_sent_folder=True):
725 """ Sends this message
726
727 :param bool save_to_sent_folder: whether or not to save it to
728 sent folder
729 :return: Success / Failure
730 :rtype: bool
731 """
732
733 if self.object_id and not self.__is_draft:
734 return RuntimeError('Not possible to send a message that is not '
735 'new or a draft. Use Reply or Forward instead.')
736
737 if self.__is_draft and self.object_id:
738 url = self.build_url(
739 self._endpoints.get('send_draft').format(id=self.object_id))
740 if self._track_changes:
741 # there are pending changes to be committed
742 self.save_draft()
743 data = None
744
745 else:
746 url = self.build_url(self._endpoints.get('send_mail'))
747 data = {self._cc('message'): self.to_api_data()}
748 if save_to_sent_folder is False:
749 data[self._cc('saveToSentItems')] = False
750
751 response = self.con.post(url, data=data)
752 # response evaluates to false if 4XX or 5XX status codes are returned
753 if not response:
754 return False
755
756 self.object_id = 'sent_message' if not self.object_id else self.object_id
757 self.__is_draft = False
758
759 return True
760
761 def reply(self, to_all=True):
762 """ Creates a new message that is a reply to this message

Callers 6

test_sendMethod · 0.80
jquery-3.4.1.jsFile · 0.80
jquery-3.5.1.jsFile · 0.80
jquery.jsFile · 0.80

Calls 6

save_draftMethod · 0.95
to_api_dataMethod · 0.95
build_urlMethod · 0.80
_ccMethod · 0.80
getMethod · 0.45
postMethod · 0.45

Tested by 3

test_sendMethod · 0.64