I've written a script which I use to save attached binary files from
e-mails to disk. The core is simply:
decodedfile = bas64.decodestring(attachment)
fle = open('image.jpg','wb')
fle.write(decodedfile)
fle.close
However, the files written to disk are regularly incomplete, i.e.
jpg's having a grey bar at the bottom, gif's don't even display, pdf's
give errors.
What am I doing wrong here?
Thanks,
Edwin 2 1840
edwinek wrote: I've written a script which I use to save attached binary files from e-mails to disk. The core is simply:
decodedfile = bas64.decodestring(attachment) fle = open('image.jpg','wb') fle.write(decodedfile) fle.close
However, the files written to disk are regularly incomplete, i.e. jpg's having a grey bar at the bottom, gif's don't even display, pdf's give errors. What am I doing wrong here?
You're not calling fle.close -- you lack parentheses after the
method, so you're just mentioning it, NOT calling it. Not sure
if that's your problem (seems unlikely), but it most definitely
IS something you're doing wrong, so I thought I'd point it out.
Alex
"edwinek" <ed***@mindless.com> wrote: I've written a script which I use to save attached binary files from e-mails to disk. The core is simply:
decodedfile = bas64.decodestring(attachment) fle = open('image.jpg','wb') fle.write(decodedfile) fle.close
However, the files written to disk are regularly incomplete, i.e. jpg's having a grey bar at the bottom, gif's don't even display, pdf's give errors.
What am I doing wrong here?
chances are that you're not closing the file before using it: try changing
the last line to
fle.close()
</F> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bjorn Jensen |
last post by:
Hello!
My resulting image har nearly same size of original (but not exact) and the
nu.jpg can be shown,
but it is modified so much, that it look totally different.... why? what to
do?
Greetings...
|
by: Stingray |
last post by:
Are there any know problems with using a MemoryStream as a backing store for
a CryptoStream? I'm trying to simply encrypt and decrypt text in memory.
I'd like to create some simple methods to...
|
by: Kelli |
last post by:
Hi there,
I'm wondering if someone can have a quick look at my code and see if
there's anything that I've done wrong. This silly script is driving
me crazy!
<%
DIM File, Upload, Count,...
|
by: gRizwan |
last post by:
Hello all,
We have a problem on a webpage. That page is sent some email data in
base64 format. what we need to do is, decode the base64 data back to
original shape and extract attached image...
|
by: Russell Stevens |
last post by:
I generate pdf files on my server and allow users to access them via a
browser and also email them. Most files work fine whether the user uses his
browser or gets an email with a pdf attachment...
|
by: mubx2000 |
last post by:
Hi ,
I'm looking for code (Symbian C++) that can do the following things:
1-Analyzing the (MIME) types (Content-typemContent-transfere-encoding,Mime Version,Conent Description).
2-Download...
|
by: William Connery |
last post by:
Hi,
I have a small python program with e-mail capabilities that I have pieced together from code snippets found on the internet.
The program uses the smtplib module to successfully send an...
|
by: olafmol |
last post by:
Hello,
i want to write a PHP4 script that reads POP3 or IMAP mail and can
decode the possible attachments in the email. I've looked around for
some classes to do this, and found a few, but most...
|
by: shilpab |
last post by:
My query is regarding the decoding classes available in Exchange 2007.
I am working on a problem where I want to decode a TNEF encoded MIME message. I am using the class Base64Decode in...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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
|
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...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |