我正在尝试使用电子邮件rolodex的数据框来对数据框中找到的索引数量迭代附件和掩体。谁能告诉我在每个设置下我如何通过下面的i引用特定的列?
谢谢

body_of_email = "This is a call to arms"
for i in email_list:
    #Send to Recipients individually from list
    m.setRecipients(i.columns[2])
    #Attachments
    m.attachments.append(excel_att)
    m.attachments.append(cover_letter)
    m.setSubject(i.columns[1] + ' I made an email script.')
    m.setBody(body_of_email)
    m.sendMessage()


email_list是3列,数字,名称,email_address

最佳答案

让我们使用itertuples

for i in email_list.itertuples():
    #Send to Recipients individually from list


使用:

    m.setRecipients(i.email_address)


要么

    m.setRecipients(i[2])
    #Attachments
    m.attachments.append(excel_att)
    m.attachments.append(cover_letter)
    m.setSubject(i.name + ' I made an email script.')


要么

    m.setSubject(i[1] + ' I made an email script.')
    m.setBody(body_of_email)
    m.sendMessage()

关于python - Python O365发送电子邮件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44638960/

10-11 13:59