邮件正文中作为内联附件的HTML表和图像不起作用-Python

邮件正文中作为内联附件的HTML表和图像不起作用-Python,python,Python,添加内联图像单独工作,添加表单独工作。但是,当我对图像和表使用msg.attach()时,邮件中只显示表,图像显示为附件。 MIMText()可以使用两次吗 def add_table(): t = html_file tab = MIMEText(t, 'html') return tab msg.attach(add_table()) exec_dashboard = 'Overall Release Execution Dashboard' priority_da

添加内联图像单独工作,添加表单独工作。但是,当我对图像和表使用msg.attach()时,邮件中只显示表,图像显示为附件。 MIMText()可以使用两次吗

def add_table():
    t = html_file
    tab = MIMEText(t, 'html')
    return tab

msg.attach(add_table())
exec_dashboard = 'Overall Release Execution Dashboard'
priority_dashboard = 'Overall Test Completion Status as per Priority'
msgText = MIMEText('<h1 style="background-color:#00022e; font-family: Calibri; font-size: 11pt; color: white; '
                   'text-align: center">%s</h1><br><img '
                   'style="border:2px solid black;" width = "600", height= "200" src="cid:%s">&nbsp;<img '
                   'style="border:2px solid black;" width = "600", height= "200" src="cid:%s"><br><h1 '
                   'style="background-color:#00022e; font-family: Calibri; font-size: 11pt; color: white; '
                   'text-align: center">%s</h1> '
                   '<br><img width = "800", height= "250" src="cid:%s\n">&nbsp;<img width = "800", height= "200" '
                   'src="cid:%s\n">' % (exec_dashboard, android_snip, iOS_snip, priority_dashboard, attachment, attachment2), 'html')
msg.attach(msgText)

fp3 = open(android_snip, 'rb')
img3 = MIMEImage(fp3.read())
fp3.close()
img3.add_header('Content-ID', '<{}>'.format(android_snip))
msg.attach(img3)

fp4 = open(iOS_snip, 'rb')
img4 = MIMEImage(fp4.read())
fp4.close()
img4.add_header('Content-ID', '<{}>'.format(iOS_snip))
msg.attach(img4)

fp = open(attachment, 'rb')
img = MIMEImage(fp.read())
fp.close()
img.add_header('Content-ID', '<{}>'.format(attachment))
msg.attach(img)

fp2 = open(attachment2, 'rb')
img2 = MIMEImage(fp2.read())
fp2.close()
img2.add_header('Content-ID', '<{}>'.format(attachment2))
msg.attach(img2)
def add_table():
t=html\u文件
tab=MIMEText(t,‘html’)
返回选项卡
msg.attach(添加表格())
exec_dashboard='总体发布执行dashboard'
优先级\仪表板='根据优先级的总体测试完成状态'
msgText=MIMEText(“%s

%s” “
”%(“执行”面板、android面板、iOS面板、优先级面板、附件、附件2)、“html”) 附加消息(msgText) fp3=打开(android_snip,'rb') img3=mimimage(fp3.read()) fp3.close() img3.add_头('Content-ID',''.format(android_-snip)) 附加消息(img3) fp4=打开(iOS_snip,'rb') img4=mimimage(fp4.read()) fp4.关闭() img4.add_头('Content-ID',''.format(iOS_snip)) 附加消息(img4) fp=打开(附件“rb”) img=mimimage(fp.read()) fp.close() img.add_标题('Content-ID',''.format(附件)) 附加消息(img) fp2=打开(附件2“rb”) img2=mimimage(fp2.read()) fp2.关闭() img2.add_标题('Content-ID',''.format(附件2)) 附加消息(img2)
我有单独的android_snip、iOS_snip和其他附件,src在粘贴在这里的代码片段上面声明。当我运行这段代码时,所有图像都显示为附件,只有htm_文件(包含该表)显示为内联表


我的查询是将html_文件和附件作为内联邮件。例如,msg.attach()带有2个变量。

您能否添加一个最小的工作代码段,以便人们能够调试您的代码并查看您迄今为止所做的工作?