[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1
48 seconds to complete an initially header load. The queue should either run faster
still, or I should delete an email once in a while!

HTML main text extraction (prototype)
PyMailGUI is still somewhat plain-text biased, despite the emergence of HTML
emails in recent years. When the main (or only) text part of a mail is HTML, it is
displayed in a popped-up web browser. In the prior version, though, its HTML
text was still displayed in a PyEdit text editor component and was still quoted for
the main text of replies and forwards.
Because most people are not HTML parsers, this edition’s version attempts to do
better by extracting plain text from the part’s HTML with a simple HTML parsing
step. The extracted plain text is then displayed in the mail view window and used
as original text in replies and forwards.
This HTML parser is at best a prototype and is largely included to provide a first
step that you can tailor for your tastes and needs, but any result it produces is better
than showing raw HTML. If this fails to render the plain text well, users can still
fall back on viewing in the web browser and cutting and pasting from there into
replies and forwards. See also the note about open source alternatives by this
parser’s source code later in this chapter; this is an already explored problem
domain.


Reply copies all original recipients by default
In this version, replies are really reply-to-all by default—they automatically prefill
the Cc header in the replies composition window with all the original recipients of
the message. To do so, replies extract all addresses among both the original To and
Cc headers, and remove duplicates as well as the new sender’s address by using set
operations. The net effect is to copy all other recipients on the reply. This is in
addition to replying to the sender by initializing To with the original sender’s
address.
This feature is intended to reflect common usage: email circulated among groups.
Since it might not always be desirable, though, it can be disabled in mailconfig so
that replies initialize just To headers to reply to the original sender only. If enabled,
users may need to delete the Cc prefill if not wanted; if disabled, users may need
to insert Cc addresses manually instead. Both cases seem equally likely. Moreover,
it’s not impossible that the original recipients include mail list names, aliases, or
spurious addresses that will be either incorrect or irrelevant when the reply is sent.
Like the Bcc prefill described in the next item, the reply’s Cc initialization can be
edited prior to sends if needed, and disabled entirely if preferred. Also see the
suggested enhancements for this feature at the end of this chapter—allowing this
to be enabled or disabled in the GUI per message might be a better approach.


Other upgrades: Bcc prefills, “Re” and “Fwd” case, list size, duplicate recipients
In addition, there have been smaller enhancements throughout. Among them: Bcc
headers in edit windows are now prefilled with the sender’s address as a conven-
ience (a common role for this header); Reply and Forward now ignore case when


1016 | Chapter 14: The PyMailGUI Client

Free download pdf