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
"None"

msg = email.message_from_string(mstring)
for part in msg.walk():
fn = part.get_filename()
if fn <>None:
filenames.append(fn)
attachedcontents.append(part.get_payload())
print "im here"
*..::CODE1:..
================================================== =========*
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()

*..::OUTPUT1::..
================================================== =========*
--__CONTENT_64564_PART_BOUNDARY__33243242__
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_64564_PART_BOUNDARY__33243242__
Content-Type: image/jpeg;
name="0815071408.jpg"
Content-ID: <0815071408.jpg>
Content-Location: 0815071408.jpg
Content-Transfer-Encoding: base64

/9j/4AkjSkZYWAAQ/9j/2wCEABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzOD dA
SFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2MBERISGBUYLx oaL2NCOEJjY2NjY2NjY2Nj
Y2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2 NjY//EAaIAAAEFAQEBAQEB
AAAAAAAAAAABAgMEBQYHCAkKCxAAAgEDAwIEAwUFBAQAAAF9AQ IDAAQRBRIhMUEGE1FhByJx
FDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3OD k6Q0RFRkdISUpTVFVWV1hZ
WmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpK Wmp6ipqrKztLW2t7i5usLD
xMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6AQ ADAQEBAQEBAQEBAAAAAAAA
AQIDBAUGBwgJCgsRAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQ YSQVEHYXETIjKBCBRCkaGx
wQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0 hJSlNUVVZXWFlaY2RlZmdo
aWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqr KztLW2t7i5usLDxMXGx8jJ
ytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/AABEIAHgAoAMBIQACEQEDEQH/2gAMAwEA
AhEDEQA/AMead5GxnJ9KjaPYuTy1YtnQlYqk7ZM1dgl3Lg1b2MzZ02TMZX 0qvr97cR2AtIjt
idsvjq1EZWkRKPMZ2j2U9xcIqxts/i4rv7SwW2gVFGB1NKb1HcfNEGXBFZstlDz8xBqAM+8Q
QoTnIrmtQuQcgGriJk3hqXF1IPUV10T5FWySXNJmkA1z8prjPE Hf/eo6jRhir9r0q2NGnDG
XqNc5frnPrULMMk/NgdqkMoTB+XjrzVO4uBgDlyfQUpWa2KS7H//2Q==
--__CONTENT_64564_PART_BOUNDARY__33243242__--

Aug 27 '07 #1
0 1047

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

Similar topics

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...
2
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...
6
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...
5
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...
3
isladogs
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...
0
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...
2
isladogs
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...
0
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...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
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...
0
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"....
0
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...
0
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.