Attached images by plain email.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gaz

    #1

    Attached images by plain email.

    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!

  • luis.armendariz@gmail.com

    #2
    Re: Attached images by plain email.

    Hi Gaz,

    Perhaps this will help?



    Comment

    • Gaz

      #3
      Re: Attached images by plain email.

      You are the man!

      Comment

      • Gaz

        #4
        Re: Attached images by plain email.

        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.j pg')
        104 base64.encode(o pen('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.Strin gIO 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'

        Comment

        • Ludwig

          #5
          Re: Attached images by plain email.

          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

          Comment

          Working...