[英]Python: Convert email address list to send email
I have email address list as below: 我的电子邮件地址列表如下:
email_list = [a@gmail.com, b@gmail.com, c@gmail.com]
I converted with below: 我转换如下:
email_string = ''.join(str(e) for e in email_list)
But I got emails are a@gmail.com b@gmail.com c@gmail.com
which can not be received email, I would like to receive email successfully(Exchange mail server). 但是我收到的电子邮件是
a@gmail.com b@gmail.com c@gmail.com
无法接收电子邮件,我想成功接收电子邮件(Exchange邮件服务器)。
my function is as below, I use Mailbox
of exchangelib
: 我的功能如下,我使用
exchangelib
Mailbox
:
to_recipients=[Mailbox(email_address=' '.join(str(e) for e in list(test.user.all().values_list('email', flat=True))))]
You have the right idea - just use a semicolon instead of an empty string when joining: 您有正确的想法-加入时只需使用分号代替空字符串:
email_string = ';'.join(str(e) for e in email_list)
# Here ---------^
While it appears that the apostrophes contain a space they actually do not. 尽管撇号似乎包含一个空格,但实际上却没有。
email_string = ''.join(str(e) for e in email_list)
is different than 与...不同
email_string = ' '.join(str(e) for e in email_list)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.