473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Retrieve Email Attachments

Hello,

I need to access a POP or mayb IMAP based email account and extract
attachments (probably images) from the email messages. How can this
be done with the current two module libraries?

Thanks for any insight.

Faizan.
Jul 18 '05 #1
5 3355
> I need to access a POP or mayb IMAP based email account and extract
attachments (probably images) from the email messages. How can this
be done with the current two module libraries?


Use poplib or imaplib to get a message as a string.
import poplib
connection = poplib.POP3("servername")
connection.user("username")
connection.pass_("password")
Then use the email module (new in 2.2) to parse this string into an
instance of email.Messsage using
import email
msg = email.message_from_string(msg_as_string)


Use the methods of the resulting email.Message instance to get the
contents of the email.

Lutz
Jul 18 '05 #2
Lutz Horn wrote:
Use poplib or imaplib to get a message as a string.
>>> import poplib
>>> connection = poplib.POP3("servername")
>>> connection.user("username")
>>> connection.pass_("password")
forgot:
msg_as_string = connection.get(number_of_message_on_server)
Then use the email module (new in 2.2) to parse this string into an
instance of email.Messsage using
>>> import email
>>> msg = email.message_from_string(msg_as_string)


Use the methods of the resulting email.Message instance to get the
contents of the email.

Jul 18 '05 #3
Fazer wrote:
Hello,

I need to access a POP or mayb IMAP based email account and extract
attachments (probably images) from the email messages. How can this
be done with the current two module libraries?

i've posted an example script non too long ago:
<http://tinyurl.com/yuhmn>

cheers,
deelan

--
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://www.deelan.com/> .
Jul 18 '05 #4
Thanks a lot for your guide!

Lutz Horn <lh*@gmx.de> wrote in message news:<2g************@uni-berlin.de>...
Lutz Horn wrote:
Use poplib or imaplib to get a message as a string.
>>> import poplib
>>> connection = poplib.POP3("servername")
>>> connection.user("username")
>>> connection.pass_("password")
forgot:
>>> msg_as_string = connection.get(number_of_message_on_server)

Then use the email module (new in 2.2) to parse this string into an
instance of email.Messsage using
>>> import email
>>> msg = email.message_from_string(msg_as_string)


Use the methods of the resulting email.Message instance to get the
contents of the email.

Jul 18 '05 #5
Wow! Exactly what I needed. Thanks a million!

deelan <gg*@zzz.it> wrote in message news:<62***********@news1.interplanet.it>...
Fazer wrote:
Hello,

I need to access a POP or mayb IMAP based email account and extract
attachments (probably images) from the email messages. How can this
be done with the current two module libraries?

i've posted an example script non too long ago:
<http://tinyurl.com/yuhmn>

cheers,
deelan

Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Didier FRAISSE | last post by:
i need to retrieve every day an email and to save his attachments for later processing. i found some piece of code in the documentation like import poplib pop = poplib.POP3(Host)...
4
by: Paul Schmidt | last post by:
Dear list: I am new to python, and I am trying to figure out the short answer on something. I want to open a POP3 mailbox, read the enclosed mail using the POP3 module, , and then process it...
3
by: LutherRevisited | last post by:
Is there a way I can put a message together without having to download any attachments there may be at the same time. I'm not having any problems dealing with attachments, but the way I'm doing...
5
by: morphex | last post by:
Hi, I have an email that's in the utf-8 encoding, and I'm getting this error message when I try to send it using smtplib: * Module smtplib, line 688, in sendmail * Module smtplib, line 485,...
2
by: will | last post by:
hi, my ISP doesn't have webmail service, so i use TcpClient & Friends to issue POP3 commands to retrieve emails, store data on a website, and use that website to view emails. it all works...
10
by: OdAwG | last post by:
Hello All, Is it possible to send an email from Access? I found a Microsoft article on how to do this but I keep getting an error "RUNTIME ERROR 438" -- Object doesn't support this property or...
2
by: oyster | last post by:
I find that the existing email moudle is some hard for me to understand, especially the part of how to set the CC, BCC and attach the files. Is there any more easy one like this p-code? import...
6
by: Watermark | last post by:
i got problem with this i m implementing web based mail system. i want to access mbox and retrieve mail from it and display it on web page.. can anybody help me.
1
by: netLynx | last post by:
Hi, I am rewriting code from VB6 using MAPI into VB.NET I need to read an attachment off an email on an Exchange Server. In the old VB6 (not written by me) they restrict the Messages.type to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.