html电子邮件鼠标在文本上

时间:2014-08-03 00:53:25

标签: python html email outlook

使用python以HTML格式发送每小时报告。需要在文本上启用鼠标,换句话说,当用户将鼠标悬停在报表标题上时,会显示某些文本。

尝试以下方法,但在阅读outlook中的电子邮件时它确实有效:

from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText

def send_html_email(msg_to_list, msg_from, msg_subject, msg_body, smtp_server):
    ''' set the subject, To, From and body of the email and send it '''
    # Create message container - the correct MIME type is multipart/alternative.
    msg = MIMEMultipart('multipart')
    msg['Subject'] = msg_subject
    msg['From'] = msg_from
    msg['To'] = ', '.join(msg_to_list)
    # Record the MIME type of the HTML body - text/html.
    part = MIMEText(msg_body, 'html')
    # Attach parts into message container.
    msg.attach(part)
    # Send the message via local SMTP server.
    s = smtplib.SMTP(smtp_server)
    # sendmail function takes 3 arguments: sender's address, recipient's address
    # and message to send - here it is sent as one string.
    s.sendmail(msg['From'], msg_to_list, msg.as_string())
    s.quit()


title = 'display this when user moves mouse over this header'
html_msg_body = '''<html><body><div align = "center">'''
html_msg_body += '''<br><br><h3 bgcolor="#00BFFF" title=%s>Stats</h3>'''%(title)
html_msg_body += '<br></body>'
html_msg_body += '<br></html>'


msg_body = html_msg_body
msg_to_list = ['me@test.com']
msg_from = 'me@test.com'
msg_subject = "Stats"
smtp_server = 'localhost'
send_html_email(msg_to_list, msg_from, msg_subject, msg_body, smtp_server)

有关需要做什么的任何帮助,以便Outlook将鼠标悬停在文本上?