(self)
return mail.get()
Prepare email message for Sendgrid

        :return: Sendgrid Email message
Prepare email message for Sendgrid
Prepare email message for Sendgrid
def _prepare_email_message(self):
        """Prepare email message for Sendgrid

        :return: Sendgrid Email message
        """
        mail = Mail()

        mail.from_email = Email(self.source)
        mail.subject = self.subject

        # personalization of email
        personalization = Personalization()

        # add multiple recipients
        for to_email in self._convert_var_type_to_list(self.destination):
            personalization.add_to(Email(to_email))
            mail.add_personalization(personalization)

        # add cc (if any)
        if self.cc:
            for cc_email in self._convert_var_type_to_list(self.cc):
                personalization.add_cc(Email(cc_email))
                mail.add_personalization(personalization)

        # add bcc (if any)
        if self.bcc:
            for bcc_email in self._convert_var_type_to_list(self.bcc):
                personalization.add_bcc(Email(bcc_email))
                mail.add_personalization(personalization)

        # add content of email
        if self.body:
            mail.add_content(Content('text/plain', self.body))
        if self.html_message:
            mail.add_content(Content('text/html', self.html_message))

        # add attachments
        if self.attachment:
            mail.add_attachment(self.attachment)

        return mail.get()
def _prepare_email_message ( self ) : mail = Mail ( ) mail . from_email = Email ( self . source ) mail . subject = self . subject # personalization of email personalization = Personalization ( ) # add multiple recipients for to_email in self . _convert_var_type_to_list ( self . destination ) : personalization . add_to ( Email ( to_email ) ) mail . add_personalization ( personalization ) # add cc (if any) if self . cc : for cc_email in self . _convert_var_type_to_list ( self . cc ) : personalization . add_cc ( Email ( cc_email ) ) mail . add_personalization ( personalization ) # add bcc (if any) if self . bcc : for bcc_email in self . _convert_var_type_to_list ( self . bcc ) : personalization . add_bcc ( Email ( bcc_email ) ) mail . add_personalization ( personalization ) # add content of email if self . body : mail . add_content ( Content ( 'text/plain' , self . body ) ) if self . html_message : mail . add_content ( Content ( 'text/html' , self . html_message ) ) # add attachments if self . attachment : mail . add_attachment ( self . attachment ) return mail . get ( )