[Fwd: Re: How to make one program connect to more than one TCP?]
Laszlo Nagy
gandalf at shopzeus.com
Mon Jun 9 05:10:59 EDT 2008
agus at cs.its.ac.id wrote:
> i want to make one program that the steps like this:
> 1. download email from email account, for example: agus at yahoo.com, saved
> in a file, for example: downloadedEmail.txt
>
Can be done via the standard imaplib module. No need to use twisted.
> 2. parsing the downloadedEmail.txt, get the sender, subject and the
> message.if there is attachmet/s, not be taken.
>
Save it as an eml file. Use the standard email.Parser module for
extracting headers.
> 3. posting the downloadedEmail.txt that has been parsed into nntp server.
> 4. open nntp client for example 'thunderbird' to acces your nntp server.
>
I have no clue about it.
> i attach my programs to u..
> it is very important for me as final project in my study class, too
> difficult for me....thanks for your help!!!
>
Well, I can send you some examples that show how to download and parse
emails from imap server. I have never used nntp before so....
Some examples are attached, and also a code fragment:
IMAPDate.py - to convert between IMAP and datetime.date
imaputils.py - to show how to connect to IMAP server and list folders on
it (you need to create your own local.py file...), also shows how to
append a new message to a folder on the imap server.
code_fragment.py - to show how to search for messages on the server and
download them as pure data string, it is NOT a complete program!
And finally, here is how you parse and email:
import email.Parser
email_data = file('test2.eml','rb').read()
parser = email.Parser.Parser()
Then you need to example "parser" and its methods.
Anyway, it is your homework, I don't think that I'm going to give more
help unless you have a specific question. :-)
Best,
Laszlo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IMAPDate.py
Type: text/x-python
Size: 1372 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20080609/9b75dd66/attachment-0003.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imaputils.py
Type: text/x-python
Size: 1285 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20080609/9b75dd66/attachment-0004.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: code_fragment.py
Type: text/x-python
Size: 4805 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20080609/9b75dd66/attachment-0005.py>
More information about the Python-list
mailing list