Attached images by plain email.

G

Gaz

Hi guys. Im doing a simple CGI form to send data by email. They are for
some technicians on field so they can send daily reports about what
they made. The thing is, i dont know how to send images attached to the
email i generate with sendmail. I put the combos in the form, but i
dont know how to say to sendmail to add them to the email the form
assembles.

Any tips?

Thanks!
 
G

Gaz

Can you help me a little bit more? Please check this out:


102 part.addheader('Content-Transfer-Encoding', 'base64')
103 body = part.startbody('image/jpeg; name=c:\check.jpg')
104 base64.encode(open('check.jpg', 'rb'), body)
105
106
base64 = <module 'base64' from '/usr/lib/python2.3/base64.pyc'>,
base64.encode = <function encode>, builtin open = <type 'file'>, body =
<StringIO.StringIO instance>

IOError: [Errno 2] No such file or directory: 'check.jpg'
args = (2, 'No such file or directory')
errno = 2
filename = 'check.jpg'
strerror = 'No such file or directory'
 
L

Ludwig

Seems like you are not providing a full path to the file 'check.jpg'.
How is your program supposed to know where in the filesystem it
is located? Either that, or you have to put the file in the same
directory that on which the program is running.

Also, you should use two backslashes in the name: part

body = part.startbody('image/jpeg; name=c:\\check.jpg')

This is because \ is the escape character in strings. If you
mean a literal backslash, it has to escape itself. Hence,
you use \\

Hope that helps!
-Luis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top