上下文: 我正在尝试将收件箱中的现有电子邮件发送到新线程。
问题: 我已使用此功能成功发送电子邮件正文,但正文丢失了原始电子邮件的格式,仅发送文本。
我认为将整个有效负载添加到请求正文中更有意义,如gmail API 页面“尝试此 API”部分中所述:
但是,当我将有效负载添加到请求正文时:
def create_message(sender, to, subject, thread_id, message_id, payload, service):
"""Create a message for an email.
Args:
sender: Email address of the sender.
to: Email address of the receiver.
subject: The subject of the email message.
message_text: The text of the email message.
Returns:
An object containing a base64url encoded email object.
"""
message = MIMEMultipart('alternative')
message['to'] = to
message['from'] = sender
message['subject'] = 'Re: %s' %subject
return {'raw': raw, 'threadId': thread_id, 'payload': payload}
发送的电子邮件没有内容。如何将现有电子邮件添加到新线程而无需解码和编码并丢失电子邮件的格式?
开心每一天1111
郎朗坤
相关分类