Thanks a lot Alan for the idea, I just tested and I had to do some 
modifications to the code:

pdfasastring = fpdfobject.output(dest="S")
import StringIO
sio = StringIO.StringIO()
sio.write(pdfasastring)
sio.seek(0)

The following instruction create a mime type for the attachment and now, 
the object created (att1) can be used in the mail object

att1 = Mail.Attachment(sio, filename="mandatory.ext")


mail.send(to=['[email protected]'],
          subject='An email with a pdf attached to it',
          message='test',
          attachments = (att1,)
)

BR
Jaime

El domingo, 17 de marzo de 2013 17:45:53 UTC-6, Alan Etkin escribió:
>
> > I'm not sure what you mean in the second option
>
> I meant that you could:
> "... even leave the filelike object which receives the fpdf output open 
> and use that instead as attachment input without the need to write to the 
> filesystem ..."
>
> > when you say filelike object what are you referring to?
>
> http://docs.python.org/2/glossary.html#term-file-object
>
> > attachments = mail.Attachment(pdf, filename='sample.pdf'))
>
> What does pdf contain?
>
> For creating the attachments, this should work for App Engine:
>
> You should be allowed to get the fpdf output as a string with something 
> like
>
> pdfasastring = fpdfobject.output(dest="S")
>
> Then store this output with a file-like object
>
> import StringIO
> sio = StringIO.StringIO()
>
> Now store the pdf string on the StringIO object
>
> sio.write(pdfasastring)
>
> Perhaps you need to return the seek position in case that the Attachment 
> class uses the .read() method
> sio.seek(0)
>
> Then, you supposedly can add an attachment with:
>
> mail.Attachment(sio, filename="mandatory.ext")
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to