我只是想知道MIMEMultipart是否具有任何属性,我可以在其中传递我的电子邮件正文部分...我仅想出的部分是
msg = MIMEMultipart()
msg["From"] = emailfrom
msg["To"] = emailto
msg["Subject"] = "hi find the attached file"
msg.preamble = "please PFA"
有什么像
msg["Body"] = I will add a string or a text file
我用谷歌搜索发现
body = MIMEMultipart('alternative')
body.attach(MIMEText(text))
但这对我来说不起作用。
还有一件事-MIMEMultipart('alternative')
工作如何?它提供什么功能?
这对我有用:
msg = MIMEMultipart()
msg['From'], msg['To'], msg['Subject'] = ... # specify your sender, receiver, subject attributes
body = 'This is the body of the email.'
body = MIMEText(body) # convert the body to a MIME compatible string
msg.attach(body) # attach it to your main message
您将附加body
到msg
,并且body
在这种情况下应为MIMEText
对象。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句