Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75968

Re: how to get the subject of email?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <elearn2014@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.137
X-Spam-Level *
X-Spam-Evidence '*H*': 0.73; '*S*': 0.00; 'skip:e 50': 0.05; 'subject:subject': 0.16; 'wrote:': 0.18; 'help.': 0.21; 'header :User-Agent:1': 0.23; 'instead.': 0.24; 'skip:e 30': 0.24; 'question': 0.24; 'header:In-Reply-To:1': 0.27; 'code': 0.31; 'writes:': 0.31; 'subject:the': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'similar': 0.36; 'received:10': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'how': 0.40; 'john': 0.61; 'charset:windows-1252': 0.65; 'subject': 0.69; 'subject:get': 0.81; 'yours.': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=2B1EOShNCkWUDu1kRKUKAnw9zLTuC74zEdD0jjtPYWk=; b=z+qASDZ+ufsYrqDOBJVfgDy6a66RIj3nDtQ1zRhp4LmnUYzIPL12Afv7i0gi7lU//b CTeuqc48Yiupj5J6vOn56GQSZ/wimcReuTLnz/K59zBeHxsI9qEWKWfaTECf0aWO+xGG SvW/BYM5tOI8lffZRl2eHHor8lxZWYbTPCvIvQEsU5wiSQxbOJJ7bMf2/e0lWC34+ynw gE1b/zq8AU/6nOQJG8cCjk1wWHF8lry2RE/ZhB6plsSnpHkejRTBLFaO9goWSFqAe1m/ 4TwQd9SjQslFamMOYwSvK5TxLRl6ewtTzS/eFv1UvD0QvMcUZ+p9ybyZyTZxEAVnFVCO hCXA==
X-Received by 10.70.140.13 with SMTP id rc13mr662220pdb.127.1407649049210; Sat, 09 Aug 2014 22:37:29 -0700 (PDT)
Date Sat, 09 Aug 2014 22:37:22 -0700
From luofeiyu <elearn2014@gmail.com>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0
MIME-Version 1.0
To python-list@python.org
Subject Re: how to get the subject of email?
References <mailman.12805.1407635303.18130.python-list@python.org> <ls6jp2$feg$2@reader1.panix.com>
In-Reply-To <ls6jp2$feg$2@reader1.panix.com>
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12807.1407649058.18130.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1407649058 news.xs4all.nl 2886 [2001:888:2000:d::a6]:36267
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75968

Show key headers only | View raw


message = email.message_from_bytes(text)

I get it ,
print(message['Subject'])  #can get the subject

But how can i get the body content of message?

no , message['Body']  or message['Content']

On 8/9/2014 7:01 PM, John Gordon wrote:
> In <mailman.12805.1407635303.18130.python-list@python.org> luofeiyu <elearn2014@gmail.com> 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.
>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

how to get the subject of email? luofeiyu <elearn2014@gmail.com> - 2014-08-09 18:41 -0700
  Re: how to get the subject of email? John Gordon <gordon@panix.com> - 2014-08-10 02:01 +0000
    Re: how to get the subject of email? luofeiyu <elearn2014@gmail.com> - 2014-08-09 22:37 -0700
    Re: how to get the subject of email? luofeiyu <elearn2014@gmail.com> - 2014-08-09 22:52 -0700

csiph-web