hi group.

I'm new to python but a veteran at programming.  This one has me
stumped.  I have a simple contact form which the user fills out.  The
email is sent to the site user as well and it is delivered with the
content in the body of the email as well in nice order.  I have
modified my code to also send the content as a csv attachment.  On the
server, the file is perfectly generated with content.  The attachment,
however, is completely blank.  Any ideas what that could be?  My code
snippet is shown below:


      if int(attachmenttype)==2 or int(attachmenttype)==3:
        for field in ctx.request.field_names():
          if field=='last_name':
            myfilename=ctx.request.field_value(field)+'.txt'
        if myfilename=='':
          myfilename='tempfile.txt'
        mypath= mynewfilepath + '/' + myfilename
        f=open(mypath, 'w')
        mynewstring=''
        counter=0
        for field in ctx.request.field_names():
          if field != 'inquiry_required':
            mynewstring=mynewstring + field +','
        if mynewstring[-1]==',':
          mynewstring=mynewstring[0:len(mynewstring)-1]
        f.write(mynewstring)
        f.write ('\n')

        mynewstring=''
        counter=1
        for field in ctx.request.field_names():
          fielddata=ctx.request.field_value(field)
          if counter==1:
            dummydata=0
          else:
            mynewstring=mynewstring + '"' + fielddata.replace('"','')
+ '",'
          counter = counter + 1
        if mynewstring[-1]==',':
          mynewstring=mynewstring[0:len(mynewstring)-1]
        f.write(mynewstring)
        f.write('\n')
        f.close
        attachments.append('/'.join((ctx.request.library,
myfilename)))

 [snip... sends email just after this]

any ideas?
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to