Unicode encoding in email
<p>I have manually created and sent myself an html email in gmail. I want to be able to reuse this html output to programatically send it (using smtplib in python).</p>

<p>In gmail, I view the source, which appears like:</p>

<blockquote>
  <p>Mime-Version: 1.0 Content-Type: multipart/alternative;
  boundary="--==_mimepart_57daadsdas2e101427152ee"; charset=UTF-8
  ----==_mimepart_57daadsdas2e101427152ee Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable</p>
  
  <p><strong>Hi all !</strong>
  =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</p>
  
  <p>Venez d=C3=A9couvrir</p>
</blockquote>

<p>My problem is that when I then try to send this content as html programatically, it's not displayed correctly. I suspect it's because of unicode conversion. I can't convert back for example the characters "d=C3=A9couvrir" to what it should be: "dÃ©couvrir".</p>

<p>Could anyone help?</p>

<p>There's are some <a href="https://docs.python.org/2/library/email-examples.html#email-examples" rel="nofollow">MIME examples</a> that are probably more suitable, but the simple answer from the headers is that it is UTF8 and <code>quoted-printable</code> encoding, so you can use the <code>quopri</code> module:</p>

<pre><code>&gt;&gt;&gt; quopri.decodestring('Venez d=C3=A9couvrir').decode('utf8')
'Venez dÃ©couvrir'
</code></pre>

python unicode unicode-string