電子メール通知を送信しようとしています。動的データを送信したいのです(テスト目的のために辞書は静的です)。どのように私は私の辞書の中で1つの値だけを電子メールに表示トラフを繰り返す。どんな助けでも大歓迎です!!!ここで pythonでdictを繰り返してHTMLメールで使用することは可能ですか?
は私が得る電子メール私のemail.pyここimport smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# me == my email address
# you == recipient's email address
me = "[email protected]"
you = "[email protected]"
msg = MIMEMultipart('alternative')
msg['Subject'] = "Link"
msg['From'] = me
msg['To'] = you
justin = "Justin"
p = {u'Contracts that need signed by: Justin': [[u'/contracts/26203', u'/contracts/26194', u'/contracts/26199', u'/contracts/26173']]}
for a in p.keys():
b = p['Contracts that need signed by: Justin']
for c, d in enumerate(b):
e = d
for f in e:
html = """\
<html>
<head></head>
<body>
<p>Contracts that need signed by """ + justin + """<br>
How are you?<br>
Here is the <a href="http://contract.mydomain.com/""" + f + """">link</a> you wanted.
</p>
</body>
</html>
"""
part2 = MIMEText(html, 'html')
msg.attach(part2)
s = smtplib.SMTP('localhost')
s.sendmail(me, you, msg.as_string())
s.quit()
です^私はそれは問題があなたにあるこの
Contracts that need signed by Justin
How are you?
#EACH OF THE LINKS WOULD BE THE NEXT VALUE IN MY DICTONARY.
Here is the link1 you wanted.
Here is the link2 you wanted.
Here is the link3 you wanted.
Here is the link4 you wanted.
それがpをループに少し奇妙であると、常に各反復( 'B =のp [用のpで同じエントリを使用します。.. 。])。 – Moberg