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


Groups > comp.lang.python > #75969

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!newsfeed1.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.133
X-Spam-Level *
X-Spam-Evidence '*H*': 0.74; '*S*': 0.00; 'skip:e 50': 0.05; 'none.': 0.16; '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; 'to:2**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; 'to:addr:gordon': 0.84; '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=9sGGNCF8ttA3zT2DanUALwN0eECW2z9yvEPic+OqOro=; b=VcVJPk5d2+KF6EVqOEWsuHeBp0txNew8iCRLS2Y2m7AoIU0Fy+D6obDeOg1zW/nSGN REbXhBpug2U25mVMvj9pkYhHBmXnnW/YVP79RBeOfj4s9+5gd0f1GRCI79VcdTdO114x tRszfJB65deja+8IXTS2u9ELYNy4joSbN0fQG/oh8lRUebkqGPYOr+mCwcLB24XV0B3c /QoY5TBm5RWs2L1Phm3kHw5hE6gd8tuZkyzhYBca+Hc+O+Rr3Z+pTA0/ZWu5kfRpZOTp B6kC7JY5OJp77k42JlKFoxaeFbaePltF8Gl36Ku25Zu8PKz2H33w2P/n7P0MTJnLGP35 GRjw==
X-Received by 10.66.121.168 with SMTP id ll8mr34514124pab.86.1407649925950; Sat, 09 Aug 2014 22:52:05 -0700 (PDT)
Date Sat, 09 Aug 2014 22:52:01 -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 John Gordon <gordon@panix.com>, 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.12808.1407649929.18130.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1407649929 news.xs4all.nl 2905 [2001:888:2000:d::a6]:39343
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75969

Show key headers only | View raw


think you ,i get it .
message = email.message_from_bytes(text)
print(message['Subject'])  #can get the subject

But how can i get the body content of message?

  message['Body']  or message['Content'] can get none.


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 | 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