Re: parsing email from stdin

2013-10-08 Thread Andreas Perstinger
On 08.10.2013 17:25, Antoon Pardon wrote: Op 08-10-13 16:24, Andreas Perstinger schreef: Looking at the docs, I've found there is also "message_from_binary_file" which works for me with your code. http://docs.python.org/3/library/email.parser.html#email.message_from_binary_file I can't try t

Re: parsing email from stdin

2013-10-08 Thread Antoon Pardon
Op 08-10-13 16:24, Andreas Perstinger schreef: On 08.10.2013 14:20, Antoon Pardon wrote: As I don't know what encoding these messages will be in, I thought it would be prudent to read stdin as binary data. Using python 3.3 on a debian box I have the following code. #!/usr/bin/python3 import s

Re: parsing email from stdin

2013-10-08 Thread Andreas Perstinger
On 08.10.2013 14:20, Antoon Pardon wrote: As I don't know what encoding these messages will be in, I thought it would be prudent to read stdin as binary data. Using python 3.3 on a debian box I have the following code. #!/usr/bin/python3 import sys from email import message_from_file sys.stdi

parsing email from stdin

2013-10-08 Thread Antoon Pardon
I want to do some postprocessing on messages from a particular mailbox. So I use getmail which will fetch the messages and feed them to stdin of my program. As I don't know what encoding these messages will be in, I thought it would be prudent to read stdin as binary data. Using python 3.3 on a

Re: HOWTO: Parsing email using Python part2

2011-07-15 Thread Steven D'Aprano
aspineux wrote: > Hello > > I have written part 2 about parsing email. > > You can find the article here : > > http://blog.magiksys.net/parsing-email-using-python-content > > This part is a lot longer : Wow! Well done. Thank you for sharing this, this is ex

Re: HOWTO: Parsing email using Python part1

2011-07-03 Thread TheSaint
aspineux wrote: > Hope this help someone. > Yeah I will learn alot and surely applying to my code. Merci Beaucoup -- goto /dev/null -- http://mail.python.org/mailman/listinfo/python-list

Re: HOWTO: Parsing email using Python part1

2011-07-03 Thread python
Alain, > I have written an article about parsing email using Python. The article is at > http://blog.magiksys.net/Parsing-email-using-python-header and the full content is here. Very helpful - thank you! Regards, Malcolm -- http://mail.python.org/mailman/listinfo/python-list

HOWTO: Parsing email using Python part1

2011-07-03 Thread aspineux
Hi I have written an article about parsing email using Python. The article is at http://blog.magiksys.net/Parsing-email-using-python-header and the full content is here. Hope this help someone. Regards. A lot of programs and libraries commonly used to send emails don't comply with RFC. I

Parsing email

2010-06-23 Thread Xianwen Chen
Hi guys, I use these codes to read emails from an IMAP server: import imaplib imap_srv_addr = "someserver" imap_srv = imaplib.IMAP4_SSL(imap_srv_addr) imap_srv.login("username","passwd") imap_srv.select("Inbox") msg = imap_srv.fetch(1, '(RFC822)') How can I parse msg so it can be appended to th

Re: Parsing Email Headers

2010-03-12 Thread Thomas Guettler
T wrote: > Thanks for your suggestions! Here's what seems to be working - it's > basically the same thing I originally had, but first checks to see if > the line is blank > > response, lines, bytes = M.retr(i+1) > # For each line in message > for li

Re: Parsing Email Headers

2010-03-11 Thread T
Thanks for your suggestions! Here's what seems to be working - it's basically the same thing I originally had, but first checks to see if the line is blank response, lines, bytes = M.retr(i+1) # For each line in message for line in lines:

Re: Parsing Email Headers

2010-03-11 Thread MRAB
T wrote: On Mar 11, 3:13 pm, MRAB wrote: T wrote: All I'm looking to do is to download messages from a POP account and retrieve the sender and subject from their headers. Right now I'm 95% of the way there, except I can't seem to figure out how to *just* get the headers. Problem is, certain

Re: Parsing Email Headers

2010-03-11 Thread T
On Mar 11, 3:13 pm, MRAB wrote: > T wrote: > > All I'm looking to do is to download messages from a POP account and > > retrieve the sender and subject from their headers.  Right now I'm 95% > > of the way there, except I can't seem to figure out how to *just* get > > the headers.  Problem is, cer

Re: Parsing Email Headers

2010-03-11 Thread Grant Edwards
On 2010-03-11, T wrote: > All I'm looking to do is to download messages from a POP account and > retrieve the sender and subject from their headers. Right now I'm 95% > of the way there, except I can't seem to figure out how to *just* get > the headers. The headers are saparated from the body by

Re: Parsing Email Headers

2010-03-11 Thread MRAB
T wrote: All I'm looking to do is to download messages from a POP account and retrieve the sender and subject from their headers. Right now I'm 95% of the way there, except I can't seem to figure out how to *just* get the headers. Problem is, certain email clients also include headers in the me

Parsing Email Headers

2010-03-11 Thread T
All I'm looking to do is to download messages from a POP account and retrieve the sender and subject from their headers. Right now I'm 95% of the way there, except I can't seem to figure out how to *just* get the headers. Problem is, certain email clients also include headers in the message body

Re: Parsing email attachments: get_payload() produces unsaveable data

2009-10-14 Thread dpapathanasiou
On Oct 4, 10:27 am, dpapathanasiou wrote: > I'm using python to access an email account via POP, then for each > incoming message, save any attachments. > > This is the function which scans the message for attachments: > > def save_attachments (local_folder, msg_text): >     """Scan the email mess

Re: Parsing email attachments: get_payload() produces unsaveable data

2009-10-04 Thread Albert Hopkins
On Sun, 2009-10-04 at 09:17 -0700, dpapathanasiou wrote: > > Which is *really* difficult (for me) to read. Any chance of providing a > > "normal" traceback? > > File "/opt/server/smtp/smtps.py", line 213, in handle > email_replier.post_reply(recipient_mbox, ''.join(data)) > File "/opt/ser

Re: Parsing email attachments: get_payload() produces unsaveable data

2009-10-04 Thread dpapathanasiou
> Which is *really* difficult (for me) to read.  Any chance of providing a > "normal" traceback? File "/opt/server/smtp/smtps.py", line 213, in handle email_replier.post_reply(recipient_mbox, ''.join(data)) File "/opt/server/smtp/email_replier.py", line 108, in post_reply save_attachm

Re: Parsing email attachments: get_payload() produces unsaveable data

2009-10-04 Thread Albert Hopkins
On Sun, 2009-10-04 at 08:16 -0700, dpapathanasiou wrote: > > And where might we be able to see that stack trace? > > This is it: > > Exception: ('AttributeError', '', [' File "/opt/server/smtp/ > smtps.py", line 213, in handle\ne > mail_replier.post_reply(recipient_mbox, \'\'.join(data))\n',

Re: Parsing email attachments: get_payload() produces unsaveable data

2009-10-04 Thread dpapathanasiou
> And where might we be able to see that stack trace? This is it: Exception: ('AttributeError', '', [' File "/opt/server/smtp/ smtps.py", line 213, in handle\ne mail_replier.post_reply(recipient_mbox, \'\'.join(data))\n', ' File "/ opt/server/smtp/email_replier.py", l ine 108, in post_repl

Re: Parsing email attachments: get_payload() produces unsaveable data

2009-10-04 Thread Albert Hopkins
On Sun, 2009-10-04 at 07:27 -0700, dpapathanasiou wrote: > When I try to write the filedata to a file system folder, though, I > get an AttributeError in the stack trace. And where might we be able to see that stack trace? -a -- http://mail.python.org/mailman/listinfo/python-list

Parsing email attachments: get_payload() produces unsaveable data

2009-10-04 Thread dpapathanasiou
I'm using python to access an email account via POP, then for each incoming message, save any attachments. This is the function which scans the message for attachments: def save_attachments (local_folder, msg_text): """Scan the email message text and save the attachments (if any) in the local

Re: help with parsing email

2008-08-18 Thread Gabriel Genellina
En Mon, 18 Aug 2008 12:24:07 -0300, Ahmed, Shakir <[EMAIL PROTECTED]> escribió: > Thanks everyone who tried to help me to parse incoming email from an exchange > server: > > Now, I am getting following error; I am not sure where I am doing wrong. I > appreciate any help how to resolve this error

Re: help with parsing email

2008-08-18 Thread Gabriel Genellina
En Mon, 18 Aug 2008 12:24:07 -0300, Ahmed, Shakir <[EMAIL PROTECTED]> escribió: > Thanks everyone who tried to help me to parse incoming email from an exchange > server: > > Now, I am getting following error; I am not sure where I am doing wrong. I > appreciate any help how to resolve this error

RE: help with parsing email

2008-08-18 Thread Ahmed, Shakir
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Werner F. Bruhin Sent: Monday, August 18, 2008 1:04 PM To: python-list@python.org Cc: [EMAIL PROTECTED] Subject: Re: help with parsing email Ahmed, Shakir wrote: > Thanks everyone who tried to help me

Re: help with parsing email

2008-08-18 Thread Werner F. Bruhin
Ahmed, Shakir wrote: Thanks everyone who tried to help me to parse incoming email from an exchange server: Now, I am getting following error; I am not sure where I am doing wrong. I appreciate any help how to resolve this error and extract emails from an exchange server. First I tried: mai

RE: help with parsing email

2008-08-18 Thread Ahmed, Shakir
but getting error Thanks sk -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gabriel Genellina Sent: Monday, August 18, 2008 6:43 AM To: python-list@python.org Cc: [EMAIL PROTECTED] Subject: Re: help with parsing email En Thu, 14 Aug 2008 12:50:57 -0300, Ahmed,

Re: help with parsing email

2008-08-18 Thread Maric Michaud
Le Monday 18 August 2008 12:43:02 Gabriel Genellina, vous avez écrit : > En Thu, 14 Aug 2008 12:50:57 -0300, Ahmed, Shakir <[EMAIL PROTECTED]> escribió: > > I need to grab/parse numeric numbers such as app number from incoming > > emails stored in Microsoft Outlook (Microsoft Exchange server) with

Re: help with parsing email

2008-08-18 Thread Gabriel Genellina
En Thu, 14 Aug 2008 12:50:57 -0300, Ahmed, Shakir <[EMAIL PROTECTED]> escribió: > I need to grab/parse numeric numbers such as app number from incoming > emails stored in Microsoft Outlook (Microsoft Exchange server) with > specified subject line. > > The email body is like this > > myregion ; tst

help with parsing email

2008-08-14 Thread Ahmed, Shakir
Hi all, I do appreciate if any one can help me for my following problem: I need to grab/parse numeric numbers such as app number from incoming emails stored in Microsoft Outlook (Microsoft Exchange server) with specified subject line. Any help with the python script is highly appreciat

Re: Parsing Email 'References' header.

2008-05-08 Thread J. Cliff Dyer
On Thu, 2008-05-08 at 14:53 +0200, Aspersieman wrote: > Hi > > I have a python script that parses email headers to extract information > from them. I need to get the _last_ messageid in the 'References' field > (http://cr.yp.to/immhf/thread.html) to create a threaded view of these > emails (the

Re: Parsing Email 'References' header.

2008-05-08 Thread David
> > "<.*>(<.*?>)" > Doesn't work if there is only one e-mail address: Here's another one: "<[^<]+>$" -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing Email 'References' header.

2008-05-08 Thread David
On Thu, May 8, 2008 at 2:53 PM, Aspersieman <[EMAIL PROTECTED]> wrote: > Hi > > I have a python script that parses email headers to extract information > from them. I need to get the _last_ messageid in the 'References' field > (http://cr.yp.to/immhf/thread.html) to create a threaded view of these

Parsing Email 'References' header.

2008-05-08 Thread Aspersieman
Hi I have a python script that parses email headers to extract information from them. I need to get the _last_ messageid in the 'References' field (http://cr.yp.to/immhf/thread.html) to create a threaded view of these emails (these messageid's are stored in a database). Now, I can easily acc

Re: Problem with parsing email message with extraneous MIMEinformation

2008-01-02 Thread Steven Allport
Thanks for the response. The section of the email is an actual message fragment. The first blank line that appears in the message is immediately after the 1st ' boundary="m.182DA3C.BE6A21A3"' There are no blank line prior to this in the message. In the example that was snipped from

Re: Problem with parsing email message with extraneous MIME information

2007-12-27 Thread sandipm
I think I faced same problem quite sometime back... but in our case, due to some settings in Microsoft outlook , forwarded emails were also coming as an attachment to email. so That attachement itself has same format as email's format, so to get information from attachment we needed to treat atta

Re: Problem with parsing email message with extraneous MIME information

2007-12-27 Thread Gabriel Genellina
En Fri, 21 Dec 2007 10:22:53 -0300, Steven Allport <[EMAIL PROTECTED]> escribió: > I am working on processing eml email message using the email module > (python > 2.5), on files exported from an Outlook PST file, to extract the > composite > parts of the email. In most instances this works f

Problem with parsing email message with extraneous MIME information

2007-12-21 Thread Steven Allport
I am working on processing eml email message using the email module (python 2.5), on files exported from an Outlook PST file, to extract the composite parts of the email. In most instances this works fine, the message is read in using message_from_file, is_multipart returns True and I can process e