python Code Robert曾经发送过Chaossearch电子邮件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Code Robert曾经发送过Chaossearch电子邮件相关的知识,希望对你有一定的参考价值。
import csv
from models import EmailTemplate, Functonym, FunctonymVariant
import random
from sendgrid import SendGridAPIClient, Substitution
from sendgrid.helpers.mail import Mail, CustomArg
subject = '<span class="functonym" data-count="4" id="0673d2ff">Search and Analytics On Amazon S3 with CHAOSSEARCH</span>'
preview = "For many companies, AWS S3 is the staging area for terabytes of analytics data, logs, and other valuable information. But..."
body = """
<p>Hi %[first_name]%,</p>
<p>For many companies, AWS S3 is the staging area for terabytes of analytics data, logs, and other valuable information. But...</p>
<ul>
<li><span class="functonym" data-count="3" id="69bd9709" contenteditable="false">
Do you have a grasp on what you’re storing on S3?</span></li>
<li>Are you maximizing the value of your S3 data?</li>
<li>Are you spending time & $$$ building & scaling analytic stacks on top of S3 (like Athena, Elasticsearch, or Hadoop)?</li>
</ul>
<p><b>CHAOS</b>SEARCH is an Amazon S3 essential that gives you the power to easily extract valuable business intelligence from your S3 data--<span class="functonym" data-count="2" id="62d55067" contenteditable="false">in place, without moving it into another data store</span>. As a result, <b>CHAOS</b>SEARCH typically cuts your analytics costs by more than 50%. </p>
<p>Let us show you how you can:</p>
<ul><li>Catalog and index all of your S3 data for easier sharing & reuse</li>
<li><span class="functonym" data-count="2" id="9fe61e59" contenteditable="false">Access unlimited data</span></li>
<li>Query, search and visualize <span class="functonym" data-count="2" contenteditable="false" id="c4f6f689">terabytes of logs, and analytic data</span> - <b><span class="functonym" data-count="2" id="f88848c5" contenteditable="false">all within your own Amazon S3 environment.</span></b></li>
<li><span class="functonym" data-count="3" contenteditable="false" id="2c29d14e">Eliminate resource requirements and improve your bottom line</span></li></ul>
<p> <span class="functonym" data-count="2" id="8e195bbe">Sign-up for a demo today.</span></p>
<p>Cheers,</p>
<p>Melodye Mueller</p>
<p><b>CHAOS</b>SEARCH</p>
"""
functonyms = [
Functonym(
"0673d2ff",
"subject",
[
FunctonymVariant("0673d2ff", "0673d2ff_1", "Search and Analytics On Amazon S3 with CHAOSSEARCH"),
FunctonymVariant("0673d2ff", "0673d2ff_2", "Search and Analytics On Amazon S3?"),
FunctonymVariant("0673d2ff", "0673d2ff_3", "Is Amazon S3 your new data lake?"),
FunctonymVariant("0673d2ff", "0673d2ff_4", "Do you know what you're storing in Amazon S3?")
]
),
Functonym(
"69bd9709",
"body",
[
FunctonymVariant("69bd9709", "69bd9709_1", "Do you have a grasp on what you’re storing on S3?"),
FunctonymVariant("69bd9709", "69bd9709_2", "Do you have access to the data you need?"),
FunctonymVariant("69bd9709", "69bd9709_3", "Can you easily search and analyze your S3 data?")
]
),
Functonym(
"62d55067",
"body",
[
FunctonymVariant("62d55067", "62d55067_1", "in place, without moving it into another data store"),
FunctonymVariant("62d55067", "62d55067_2", "with no extraction, transformation or loading")
]
),
Functonym(
"9fe61e59",
"body",
[
FunctonymVariant("9fe61e59", "9fe61e59_1", "Access unlimited data"),
FunctonymVariant("9fe61e59", "9fe61e59_2", "Increase data retention")
]
),
Functonym(
"c4f6f689",
"body",
[
FunctonymVariant("c4f6f689", "c4f6f689_1", "terabytes of logs, and analytic data"),
FunctonymVariant("c4f6f689", "c4f6f689_2", "10 - 100 times more data than previously possible")
]
),
Functonym(
"f88848c5",
"body",
[
FunctonymVariant("f88848c5", "f88848c5_1", "all within your own Amazon S3 environment."),
FunctonymVariant("f88848c5", "f88848c5_2", "all without moving data from Amazon S3")
]
),
Functonym(
"2c29d14e",
"body",
[
FunctonymVariant("2c29d14e", "2c29d14e_1", "Eliminate resource requirements and improve your bottom line"),
FunctonymVariant("2c29d14e", "2c29d14e_2", "Eliminate managing complex Elasticsearch clusters"),
FunctonymVariant("2c29d14e", "2c29d14e_3", "Eliminate supporting complex and growing Elasticsearch clusters")
]
),
Functonym(
"8e195bbe",
"body",
[
FunctonymVariant("8e195bbe", "8e195bbe_1", 'Sign up for a <a href="http://chaossearch.io/demo/">demo</a> today.'),
FunctonymVariant("8e195bbe", "8e195bbe_2", 'Sign up for a <a href="http://chaossearch.io/trial/">trial</a> today.'),
FunctonymVariant("8e195bbe", "8e195bbe_3", '<a style="background-color:#333333;border:1px solid #333333;border-color:#333333;border-radius:6px;border-width:1px;color:#ffffff;display:inline-block;font-family:arial,helvetica,sans-serif;font-size:16px;font-weight:normal;letter-spacing:0px;line-height:16px;padding:12px 18px 12px 18px;text-align:center;text-decoration:none" href="https://chaossearch.io/demo/" target="_blank">Get a Demo</a>'),
FunctonymVariant("8e195bbe", "8e195bbe_4", '<a style="background-color:#333333;border:1px solid #333333;border-color:#333333;border-radius:6px;border-width:1px;color:#ffffff;display:inline-block;font-family:arial,helvetica,sans-serif;font-size:16px;font-weight:normal;letter-spacing:0px;line-height:16px;padding:12px 18px 12px 18px;text-align:center;text-decoration:none" href="https://chaossearch.io/demo/" target="_blank">Sign up for a Free Trial</a>')
]
)
]
# contacts = [
# {'first_name': 'Jeffrey', 'email': 'jeffrey.finkelstein@gamalon.com'},
# {'first_name': 'Po', 'email': 'po.bhattacharyya@gamalon.com'},
# {'first_name': 'Jeffrey', 'email': 'jeffrey.finkelstein@gamalon.com'},
# {'first_name': 'Matt', 'email': 'matt.tharp@gamalon.com'},
# {'first_name': 'Jon', 'email': 'jon.linton@gamalon.com'},
# {'first_name': 'Alan', 'email': 'alan.delespinasse@gamalon.com'},
# {'first_name': 'Elise', 'email': 'elise.hymes@gamalon.com'}
# ] * 4
# contacts = [{'first_name': 'Robert', 'email': 'robert.ness@gamalon.com'}] * 4
contacts = []
with open('CHAOSSEARCH POC List_200_mm.csv') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
for row in readCSV:
contacts.append({'email': row[1], 'first_name': row[3]})
email_template = EmailTemplate(subject, preview, body, functonyms)
for contact in contacts:
email_instance = email_template.generate_email_instance('melodye@chaossearch.gmln.io', contact['email'])
message = Mail(
from_email=email_instance.from_address,
to_emails=email_instance.to_address,
subject=email_instance.subject,
html_content=email_instance.body.replace("<", "<").replace(">", ">")
)
message.substitution = Substitution('%[first_name]%', contact['first_name'], p=0)
message.custom_arg = CustomArg(
'functonym_variants',
[variant._asdict() for variant in email_instance.functonym_variants]
)
try:
sg = SendGridAPIClient('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')
response = sg.send(message)
print(response.status_code)
print(response.body)
print(response.headers)
except Exception as e:
print(str(e))
以上是关于python Code Robert曾经发送过Chaossearch电子邮件的主要内容,如果未能解决你的问题,请参考以下文章