Beispiel #1
0
    def ToProto(self):
        """Does addition conversion of recipient fields to protocol buffer.

    Returns:
      MailMessage protocol version of mail message including sender fields.
    """
        message = super(EmailMessage, self).ToProto()

        for attribute, adder in (('to', message.add_to),
                                 ('cc', message.add_cc), ('bcc',
                                                          message.add_bcc)):
            if hasattr(self, attribute):
                for address in _email_sequence(getattr(self, attribute)):
                    adder(_to_str(address))
        for name, value in getattr(self, 'headers', {}).iteritems():
            header = message.add_header()
            header.set_name(name)
            header.set_value(_to_str(value))
        return message
  def ToProto(self):
    """Does addition conversion of recipient fields to protocol buffer.

    Returns:
      MailMessage protocol version of mail message including sender fields.
    """
    message = super(EmailMessage, self).ToProto()

    for attribute, adder in (('to', message.add_to),
                             ('cc', message.add_cc),
                             ('bcc', message.add_bcc)):
      if hasattr(self, attribute):
        for address in _email_sequence(getattr(self, attribute)):
          adder(_to_str(address))
    for name, value in getattr(self, 'headers', {}).iteritems():
      header = message.add_header()
      header.set_name(name)
      header.set_value(_to_str(value))
    return message