我正在使用smtplib将图像作为附件发送,并将其作为email.mime.base.MIMEBase
对象附加。这些图像显示在电子邮件正文中。我希望这些图像是可点击的。是否可以为每个图像添加hrefs?
以下是附加图片的代码:
msg = MIMEMultipart()
msg['From'] = email_username
msg['To'] = ", ".join(destination_list)
msg['Subject'] = "Subject goes here"
message_body = "<b>Message body</b>"
msg.attach(MIMEText(message_body, 'html'))
part = MIMEBase('application', 'octet-stream')
part.set_payload(open('attachment.png','rb').read())
encoders.encode_base64(part)
part.add_header('Content-Disposition')
msg.attach(part)