[Tutor] how to get an email attachment

shawn bright nephish at gmail.com
Tue Aug 22 02:22:16 CEST 2006


Yes, indeed. I found in the essential reference book. It looks like it works
in the email module also. I will try a few things out here and let you know
how it goes.
thanks.

shawn

On 8/21/06, Alan Gauld <alan.gauld at freenet.co.uk> wrote:
>
> I'm no expert here, but isn't there a Mime module for
> handling mail attachments? Might be worth a look.
>
> Alan G.
>
> ----- Original Message -----
> From: "shawn bright" <nephish at gmail.com>
> To: "tutor-python" <tutor at python.org>
> Sent: Monday, August 21, 2006 9:50 PM
> Subject: [Tutor] how to get an email attachment
>
>
> > lo there pythoneers !
> >
> > i have a simple script to pull some emails from a pop server.
> > so far, its working. What i need to do is get an attachment. That
> > attachment
> > is going to be encoded in base 64.
> > so, i am looking and i can't find how to get the attachment. I have
> > some
> > info on the base64 module, so i shouldn't have a problem when i get
> > it...
> >
> > here is what i have so far....
> >
> > #!/usr/bin/python
> >
> > import poplib
> > import string
> > import time
> >
> > server = poplib.POP3('mail.xit.net')
> > server.user('moulder')
> > server.pass_('trustno1')
> >
> > # server.list returns message info from server in
> > # form of response, message_list, size where message_list
> > # is a list of messages in form of 'message_id size'
> > message_list = server.list()
> >
> > i = 0
> > for message in message_list[1]:
> >    i += 1
> >
> >    message_parts = string.split(message,' ')
> >    message_id = message_parts[0]
> >    print 'message id is %s\n' % message_id
> >    total_email_message = server.retr(message_id)[1]
> >    for line in total_email_message:
> >        print line
> >    print 'deleting message....'
> >    # not deleting for right now
> >    # server.dele(message_id)
> >    time.sleep(1)
> >    print 'done'
> >
> > server.quit()
> >
> > any ideas would be greatly appreciated.
> > if you have read this far down, thanks for your time.
> >
> > sk
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060821/89874bd2/attachment.html 


More information about the Tutor mailing list