Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!usenet.stanford.edu!panix!gordon From: John Gordon Newsgroups: comp.lang.python Subject: Re: how to get the subject of email? Date: Sun, 10 Aug 2014 02:01:06 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 16 Message-ID: References: NNTP-Posting-Host: panix2.panix.com X-Trace: reader1.panix.com 1407636066 15824 166.84.1.2 (10 Aug 2014 02:01:06 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Sun, 10 Aug 2014 02:01:06 +0000 (UTC) User-Agent: nn/6.7.3 Xref: csiph.com comp.lang.python:75965 In luofeiyu writes: > message = email.message_from_string(str(text)).get('subject') > message # nothing displayed Try using email.message_from_bytes() instead. Also have a look at http://stackoverflow.com/questions/19508393/python-email-parsing-issue for a question very similar to yours. Perhaps something in the code will help. -- John Gordon Imagine what it must be like for a real medical doctor to gordon@panix.com watch 'House', or a real serial killer to watch 'Dexter'.