browser insert(' 'fulltextbrowser pack(expand=yesfill=bothelseemore useful pyedit text editor wintitle raw message textbrowser texteditor texteditormainpopup(selfwintitle=wintitlebrowser update(browser setalltext(fulltextbrowser clearmodified(def onviewformatmail(self)""possibly threadedview selected messages pop up formatted display not threaded if in savefile listor messages are already loaded the after action runs only if getmessages prefetch allowed and worked ""msgnums self verifyselectedmsgs(if msgnumsself getmessages(msgnumsafter=lambdaself contviewfmt(msgnums)def contviewfmt(selfmsgnums)""finish viewextract main textpopup view window(sto displayextracts plain text from html text if requiredwraps text lineshtml mailsshow extracted textthen save in temp file and open in web browserpart can also be opened manually from view window split or part buttonif non-multipartotherpart must be opened manually with split or part buttonverify html open per mailconfig for html-only mailsmain text is str herebut save its raw bytes in binary mode to finesse encodingsworth the effort because many mails are just html todaythis first tried encoding guesses (utf- latin- platform dflt)but now gets and saves raw bytes to minimize any fidelity lossif part is later opened on demandit is saved in binary file as raw bytes in the same waycaveatthe spawned web browser won' have any original email headersit may still have to guess or be told the encodingunless the html already has its own encoding headers (these take the form of html tags within sections if presentnone are inserted in the html hereas some well-formed html parts have them)ie seems to handle most html part files anyhowalways encoding html parts to utf- may suffice toothis encoding can handle most types of text""for msgnum in msgnumsfulltext self getmessage(msgnum str for parser message self parsemessage(fulltexttypecontent self findmaintext(message unicode decoded if type in ['text/html''text/xml'] get plain text content html text html text(contentcontent wraplines wraptext (contentmailconfig wrapszviewwindow(headermap messageshowtext contentorigmessage message decodes headers pymailgui implementation