Parse “math340-05 =?UTF-8?B?4oCTIEF1ZmdhYmUgNS4x?=”
<p>I want to extract the subject from an email which is stored in an <code>.eml</code> file using Python 3:</p>

<p>The subject line from the file is the following:</p>

<pre><code>Subject: math340-05 =?UTF-8?B?4oCTIEF1ZmdhYmUgNS4x?=
</code></pre>

<p>I try to parse the name using the <code>email</code> module, but it returns the string as is:</p>

<pre><code>with open(filename, "r") as f:
    m = email.message_from_file(f)

print(m["Subject"])
</code></pre>

<p>How can I decode that?</p>
