bodytext encode(bodytextencodingexcept (unicodeerrorlookuperror)bodytextencoding 'utf- lookupbad encoding name general code point scheme resolve any text part attachment encodings attachesencodings [config mailconfig attachmenttextencoding for filename in self attachesif not istextkind(filename)attachesencodings append(noneskip non-textdon' ask elif config !noneattachesencodings append(configfor all text parts if set elseprompt 'enter unicode encoding name for %filename asknow askstring('pymailgui'promptattachesencodings append(asknow or 'latin- 'last chanceuse utf- if can' decode per prior selections choice attachesencodings[- if choice !none and choice !'utf- 'tryattachbytes open(filename'rb'read(attachbytes decode(choiceexcept (unicodeerrorlookuperrorioerror)attachesencodings[- 'utf- return bodytextencodingattachesencodings def onsend(self)""threadedmail edit window send button pressmay overlap with any other threaddisables none but quitexit,fail run by threadchecker via queue in after callbackcaveatno progress herebecause send mail call is atomicassumes multiple recipient addrs are separated with ','mailtools module handles encodingsattachmentsdateetcmailtools module also saves sent message text in local file now fully parses to,cc,bcc (in mailtoolsinstead of splitting on the separator naivelycould also use multiline input widgets instead of simple entrybcc added to envelopenot headers unicode encodings of text parts is resolved herebecause it may require gui promptsmailtools performs the actual encoding for parts as needed and requested headers are already decoded in the gui fields hereencoding of any non-ascii headers is performed in mailtoolsnot herebecause no gui interaction is required""resolve unicode encoding for text partsbodytextencodingattachesencodings self resolveunicodeencodings(pymailgui implementation