Пример #1
0
    def send_email(self, body=None, subject=None, to=list, cc=None, bcc=None,
                   send_as=None, attachments=None):
        """Sends an email in one method, a shortcut for creating an instance of
        :class:`Message <pyOutlook.core.message.Message>` .

        Args:
            body (str): The body of the email
            subject (str): The subject of the email
            to (list): A list of :class:`Contacts <pyOutlook.core.contact.Contact>`
            cc (list): A list of :class:`Contacts <pyOutlook.core.contact.Contact>` which will be added to the
                'Carbon Copy' line
            bcc (list): A list of :class:`Contacts <pyOutlook.core.contact.Contact>` while be blindly added to the email
            send_as (Contact): A :class:`Contact <pyOutlook.core.contact.Contact>` whose email the OutlookAccount
                has access to
            attachments (list): A list of dictionaries with two parts
                [1] 'name' - a string which will become the file's name
                [2] 'bytes' - the bytes of the file.

        """
        email = Message(self, body, subject, to, cc=cc, bcc=bcc, sender=send_as,)

        if attachments is not None:
            for attachment in attachments:
                email.attach(attachment.get('bytes'), attachment.get('name'))

        email.send()
Пример #2
0
    def test_message_sent_with_contact_recipients(self):
        """ A list of strings or Contacts can be provided as the To/CC/BCC recipients """
        mock_post = Mock()
        mock_post.status_code = 200
        self.mock_post.return_value = mock_post

        message = Message(self.account, '', '', [Contact('*****@*****.**')])
        message.send()