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

saving .zip or .txt email attachments instead of deleting them

How would I go about retriving an email message and stripping out the
attachment into a file. I have seen examples where they would read in
the file and delete the attachment and replace it with text saying that
the attachment was removed.

For testing purposes Im using a pop3 server to receive messages from. I
can log into the pop3 server get all the messages and print them to the
screen or to a file.

I have another script that I got from ActiveSource that deletes the
attachment. This is where I will need to save the attachment instead of
deleting it. Any help is appreciated thanks!

--Barry

Jul 19 '05 #1
6 2615
"scrimp" <sc*******@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
How would I go about retriving an email message and stripping out the
attachment into a file. I have seen examples where they would read in
the file and delete the attachment and replace it with text saying that
the attachment was removed.

For testing purposes Im using a pop3 server to receive messages from. I
can log into the pop3 server get all the messages and print them to the
screen or to a file.

I have another script that I got from ActiveSource that deletes the
attachment. This is where I will need to save the attachment instead of
deleting it. Any help is appreciated thanks!
Look at the documentation for the email module in the Python Library
Reference. The final example shows how to read an email and save
all the parts into a directory. It's almost usable as is; I had to tweak
it just a little for what I wanted it to do.

John Roth

--Barry


Jul 19 '05 #2
Im using the winpython IDE to run that script for the unpacking the
email. The usage says unpackmail [options] msgfile. I type unpackmail
-d filename and it gives me a syntax error. What modifications did u do
to that module to make it work?

Jul 19 '05 #3
OK i got past that syntax error I think. This is the error I am getting
now....AttributeError: 'NoneType' object has no attribute 'lower' All
Im reading is a text file of the email message with an attachment --zip
file

Jul 19 '05 #4
scrimp wrote:
OK i got past that syntax error I think. This is the error I am getting
now....AttributeError: 'NoneType' object has no attribute 'lower' All
Im reading is a text file of the email message with an attachment --zip
file


Always post a *complete* traceback, with the line numbers and all, cut
and pasted from the output window. That way there's no chance we will
misunderstand the error you are getting or have to guess at what's
really happening.

-Peter
Jul 19 '05 #5

"scrimp" <sc*******@yahoo.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Im using the winpython IDE to run that script for the unpacking the
email. The usage says unpackmail [options] msgfile. I type unpackmail
-d filename and it gives me a syntax error. What modifications did u do
to that module to make it work?
I always run it from the command line. With all due respect to the
authors, there are too many problems with command execution in
PythonWin for me to bother. These aren't precisely bugs, but they
are environmental limitations which make it impractical to use it the
way I usually use it.

And as Peter said, please cut and paste the complete output, including
the command you entered. Thanks.

John Roth


Jul 19 '05 #6
Here is the complete traceback..sorry about that though.

I used the run button and entered in "C:\email.txt" for the msgfile
parameter thats used for input

This email.txt file has a zip file attached to it and is all in text,
so hopefully I am working with the correct input file. I used the pop3
example given in the python documentation to pick up a message on the
mail server and read and wrote the information to a file --> email.txt

Traceback (most recent call last):
File
"C:\PYTHON23\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py" ,
line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\My Documents\python scripts\EmailUnpack.py", line 83, in ?
main()
File "C:\My Documents\python scripts\EmailUnpack.py", line 71, in
main
ext = mimetypes.guess_extension(part.get_type())
File "C:\PYTHON23\lib\mimetypes.py", line 178, in guess_extension
extensions = self.guess_all_extensions(type, strict)
File "C:\PYTHON23\lib\mimetypes.py", line 157, in
guess_all_extensions
type = type.lower()
AttributeError: 'NoneType' object has no attribute 'lower'

Again, thanks!

--Barry

Jul 19 '05 #7

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

Similar topics

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...
2
by: brettk | last post by:
Hello All, Here's what I'm trying to do: I need to connect to a pop3 server, download all messages, and copy all of the attachments into a specific directory. The actual email message is...
5
by: paii, Ron | last post by:
How do I setup a email with attachment for preview but require the user to push the SEND button in Outlook. I have the following function but it sends the email without the sender ever seeing it. ...
2
by: Steve | last post by:
How do you programatically save files that are attached to an email to a specified folder? It could be one file or multiple files attached to the email. Can it be done if Outlook Express is being...
1
by: nabil m | last post by:
hi i have 5 checkboxes i would like to when the user click on 1 or multiple checkbox i would like to email 1 or multiple files attachments to them ex: mailMsg.Attachments.Add(myAttachment+i); but...
1
by: Jules Mitland | last post by:
I dont have Jmail v4 due to ISP limitations. Is there any other way I can decode an email to save the attachments? I can do the first part of saving the emails using Perl. Is it possible to use any...
0
by: Karen Grube | last post by:
Hi! I hate to bother you all with this, but I don't know how best to approach a particular task. Here's the deal: Once a month I personally (that is, in my own personal inbox on my...
6
by: c_shah | last post by:
how to save outlook email attachments using VB.net?
107
by: bonneylake | last post by:
Hey Everyone, Well for the last few days i been trying to figure out how to delete attachments and download attachments to my computer. The deleting is sort of working and i don't know where 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.