本文整理汇总了Python中mailsnake.MailSnake.campaignCreate方法的典型用法代码示例。如果您正苦于以下问题:Python MailSnake.campaignCreate方法的具体用法?Python MailSnake.campaignCreate怎么用?Python MailSnake.campaignCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailsnake.MailSnake
的用法示例。
在下文中一共展示了MailSnake.campaignCreate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_campaign
# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import campaignCreate [as 别名]
def create_campaign(html, text):
mc = MailSnake(settings.MC_API_KEY)
options = {
"subject": datetime.today().strftime(settings.SUBJECT_TEMPLATE),
"from_email": settings.MC_EMAIL,
"from_name": settings.MC_FROM_NAME,
"to_name": settings.MC_TO_NAME,
"template_id": find_template(settings.MC_TEMPLATE_NAME),
"list_id": find_list(settings.MC_LIST_NAME),
}
section_name = "html_" + settings.MC_TEMPLATE_SECTION
content = {section_name: html, "text": text}
cid = mc.campaignCreate(type="regular", content=content, options=options)
return cid
示例2: create_campaign
# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import campaignCreate [as 别名]
def create_campaign(html, text):
mc = MailSnake(settings.MC_API_KEY)
options = {
'subject' : datetime.today().strftime(settings.SUBJECT_TEMPLATE),
'from_email' : settings.MC_EMAIL,
'from_name' : settings.MC_FROM_NAME,
'to_name' : settings.MC_TO_NAME,
'template_id' : find_template(settings.MC_TEMPLATE_NAME),
'list_id' : find_list(settings.MC_LIST_NAME)
}
section_name = 'html_' + settings.MC_TEMPLATE_SECTION
content = {section_name: html, "text": text}
cid = mc.campaignCreate(type='regular', content=content, options=options)
return cid
示例3: MailSnake
# 需要导入模块: from mailsnake import MailSnake [as 别名]
# 或者: from mailsnake.MailSnake import campaignCreate [as 别名]
results = parser.parse_args()
except IOError, msg:
parser.error(str(msg))
markdown = results.m
moptions = {}
moptions['list_id'] = results.l
moptions['subject'] = results.s
moptions['title'] = results.t
moptions['from_email'] = results.f
moptions['from_name'] = results.n
moptions['to_name'] = results.r
moptions['template_id'] = results.p
mailchimp = MailSnake(results.k)
newsletter = results.m.read()
results.m.close
markdowner = markdown2.Markdown()
mhtml = markdowner.convert(newsletter)
mtext = ''.join(BeautifulSoup(mhtml).findAll(text=True))
mcontent = {}
mcontent['html_MAIN'] = mhtml
mcontent['text'] = mtext
campaignid = mailchimp.campaignCreate(type='regular', options=moptions, content=mcontent)
print 'Campaign sucessfully posted to Mailchimp as:' + campaignid