Python 问题,使用不同的模板发送批量电子邮件?

我正在尝试使用 Python 自动化我的冷电子邮件销售流程。我基本上想把一堆信息放到一个谷歌表中。Google 表格中的列值为姓名、电子邮件、公司、跟进、新闻项目。来自以下值的跟进(试图找出一种跟踪跟进数量的方法):是,#1,#2,否

我能够从 Google 表格中读取数据,并且能够发送电子邮件。

这是谷歌表`。

这是我的代码:

import csv

import smtplib

import gspread

import pandas as pd

import pprint

from oauth2client.service_account import ServiceAccountCredentials

from emailsettings import USERNAME, PASSWORD

from email.mime.text import MIMEText

from email.mime.multipart import MIMEMultipart


scope = ['https://spreadsheets.google.com/feeds','https://www.googleapis.com/auth/drive']

creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)

client = gspread.authorize(creds)


sheets = client.open('Example').sheet1


sh = client.open_by_url('https://docs.google.com/spreadsheets/d/1RkzEkCJ4kEbdsW4-LqyO8bKTKBm9XlXrMp49UxIpotQ/edit#gid=0')

sheet = sh.get_worksheet(0)


data1 = sheet.get_all_values()


smtp = smtplib.SMTP('smtp.gmail.com',port=587,timeout=10)


smtp.starttls()

smtp.login(USERNAME,PASSWORD)


INITIAL_MESSAGE = """

Hi {},


I came across your name while looking for contacts at {}. Huge fan of your work. 


I'm a person and I'm the founder and COO of this company. This Company is a full-service internet marketing agency, specializing in social media advertising. We've worked with Fortune 500 Company and many others. 


I'm reaching out because we've helped several companies with increasing their ROI and wanted to see if you were open to discussing your digital goals for 2019. 


Would you be open to hop on a quick call? Here's my schedule for the week. 


Looking forward to hearing from you. 


Thanks, Name


它打印出“公司”并给我这个错误:


NameError: name 'subject' is not defined

我的目标是用有关电子邮件、个人、公司和新闻项目的信息填充电子表格。填写电子表格并运行脚本后,它将跟踪跟进次数并根据多个可用模板生成电子邮件。


我听说通过创建类、方法和属性会更容易,但不确定如何做到这一点。


守候你守候我
浏览 185回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python