How to create and send a pdf attachment

416 views
Skip to first unread message

Epinephrine

unread,
Dec 2, 2008, 7:26:05 PM12/2/08
to Django users
Does anyone have a code sample that shows how to create a pdf document
and then, without saving that document to disk, email it as an
attachment?

I am using the ReportLab PDF library at the platypus level for pdf
creation.

For emailing, I expect to use Django's EmailMessage class.

Thanks!

Thomas Guettler

unread,
Dec 3, 2008, 3:59:22 AM12/3/08
to django...@googlegroups.com
Epinephrine schrieb:
Hi,

looking at the source:

django/core/mail.py:

def attach(self, filename=None, content=None, mimetype=None):
"""
Attaches a file with the given filename and content. The
filename can
be omitted (useful for multipart/alternative messages) and the
mimetype
is guessed, if not provided.

If the first parameter is a MIMEBase subclass it is inserted
directly
into the resulting message attachments.
"""


--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

Epinephrine

unread,
Dec 3, 2008, 3:14:57 PM12/3/08
to Django users
Thanks. That is the outline of what I want to do; what I need now is
specifics: how to create the document and pass it successfully (MIME,
etc) to the attach method.

On Dec 3, 12:59 am, Thomas Guettler <h...@tbz-pariv.de> wrote:
> Epinephrine schrieb:> Does anyone have a code sample that shows how to create apdfdocument
> > and then, without saving that document to disk,emailit as an
> > attachment?
>
> > I am using the ReportLabPDFlibrary at the platypus level forpdf
> > creation.
>
> > For emailing, I expect to use Django's EmailMessage class.
>
> Hi,
>
> looking at the source:
>
> django/core/mail.py:
>
>     def attach(self, filename=None, content=None, mimetype=None):
>         """
>         Attaches a file with the given filename and content. The
> filename can
>         be omitted (useful for multipart/alternative messages) and the
> mimetype
>         is guessed, if not provided.
>
>         If the first parameter is a MIMEBase subclass it is inserted
> directly
>         into the resulting message attachments.
>         """
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/
Reply all
Reply to author
Forward
0 new messages