473,231 Members | 1,623 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,231 software developers and data experts.

POP3 - Saving an image attachment only.

I wrote some code below (Code1 block) which will read a pop3 email account
and will open each email in the inbox.
What I want my code to do is only pull the attachment; as you see below I
basically output everything. Is there an easy way to just pull
attachments? (NOTE, the only attachements that I want to pull are images)
================================================== =========
I also tried this, but for some reason the part.get_filename Always equal

msg = email.message_from_string(mstring)
for part in msg.walk():
fn = part.get_filename()
if fn <>None:
print "im here"
================================================== =========*
for email in items:
id, size = string.split(email)
resp, text, octets = server.retr(id)
text = string.join(text, "\n")
file = StringIO.StringIO(text)
message = rfc822.Message(file)
print message.fp.read()

================================================== =========*
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by
njbrmotmta9.vzwpix.com id l7LIT1GZ008951

Some email text

Content-Type: image/jpeg;
Content-ID: <0815071408.jpg>
Content-Location: 0815071408.jpg
Content-Transfer-Encoding: base64

WmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpK Wmp6ipqrKztLW2t7i5usLD
aWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqr KztLW2t7i5usLDxMXGx8jJ
AhEDEQA/AMead5GxnJ9KjaPYuTy1YtnQlYqk7ZM1dgl3Lg1b2MzZ02TMZX 0qvr97cR2AtIjt
QoTnIrmtQuQcgGriJk3hqXF1IPUV10T5FWySXNJmkA1z8prjPE Hf/eo6jRhir9r0q2NGnDG

Aug 27 '07 #1
0 1047

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

Similar topics

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...
by: Ken Yu | last post by:
Hi, I want to make a program for receive E-mail by POP3, and forward to another E-mail Account, if the E-mail with Attachment , will delete the attachment before forward, where can i find more...
by: Eddie | last post by:
Hi all, I am displaying a number of reports, and giving the users an option to display them on the web or download them to Excel. If they want the Excel file, I just use the PHP header command...
by: Craig Buchanan | last post by:
I would like to monitor a POP3 mailbox with multiple clients. However, I want to ensure that each message is processed by only one client. In essence, I would like to treat a POP3 mailbox like a...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.