简体   繁体   English

在python中使用google api添加多个收件人?

[英]Adding multiple recipients using google api in python?

I have been using the guides for the gmail api to create drafts. 我一直在使用gmail api的指南来创建草稿。 The following code has been working well. 以下代码运行良好。

def create_message(sender, to, subject, message_text):

  message = MIMEText(message_text)
  message['to'] = to
  message['from'] = sender
  message['subject'] = subject
  return {'raw': base64.urlsafe_b64encode(message.as_string())}

My question is, how do I add multiple recipients? 我的问题是,如何添加多个收件人? The API guides seem to not mention anything of the sort. API指南似乎没有提到任何类型。

MIMEText需要一串逗号分隔的收件人:

message['to'] = 'me@gmail.com, you@gmail.com'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM