Afficher des mails au format HTML
Bonjour,
Je cherche à afficher mes mails avec python.
Le corps des mails ont différents formats, certains sont du text brut, d'autres sont en html?
Comment faire pour lire les mails?
Surtout comment faire pour lire les mails en HTML?
voila ce que j'ai tenté :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
self.webview = WebKit.WebView()
self.webview.set_custom_encoding('UTF-8')
self.webview.show()
self.webview_container = self.builder.get_object('webview_container')
self.webview_container.add(self.webview)
self.webview_container.show()
....
for i_uid in uid_list:
i, uid = i_uid.split()
if uid == selected_uid:
msg = "\n".join(conn[1].retr(i)[1])
msg = message_from_string(msg)
if msg.is_multipart():
print msg.get_content_type()
for part in msg.get_payload():
print part.get_content_type()
print part.get_content_maintype()
if part.get_content_maintype() == "image":
continue
print part.get_payload()
self.webview.open(part.get_payload())
else:
print msg.get_content_type()
print msg.get_payload() |
Merci d'avance car là je bloque