我很难确定文本电子邮件正文是否以base64编码。 如果它然后使用这一行代码; 利用Jython的2.2.1如何确定电子邮件是否是Base64编码的?
dirty=base64.decodestring(dirty)
其他的继续正常。
这是我的atm代码。什么行代码可以让我从邮件中提取这样的:
“内容传输编码:的base64”
import email, email.Message
import base64
def _get_email_body(self):
try:
parts=self._email.get_payload()
check=parts[0].get_content_type()
if check=="text/plain":
part=parts[0].get_payload()
enc = part[0]['Content-Transfer-Encoding']
if enc == "base64":
dirty=base64.decodestring(dirty)
elif check=="multipart/alternative":
part=parts[0].get_payload()
enc = part[0]['Content-Transfer-Encoding']
if part[0].get_content_type()=="text/plain":
dirty=part[0].get_payload()
if enc == "base64":
dirty=base64.decodestring(dirty)
else:
return "cannot obtain the body of the email"
else:
return "cannot obtain the body of the email"
return dirty
except:
raise
OKAY此代码的工作吧!感谢所有
如果你能告诉我们你正在使用什么MIME库对象,它可以帮助人们回答你。你在使用Python库还是Java对象? – 2008-11-28 02:53:24
好的谢谢你的提醒,通常对此很好! – Setori 2008-11-28 03:32:41