Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Attachments

An email message can include file attachments. The attachments field of an email message accepts a list of either two-value tuples, or Attachment objects.

If tuples are used, one tuple must be created for each attachment. The first element of each tuple is the filename to use for the attachment in the message, and the second element is the data, as a byte string.

from google.appengine.api import mail
from google.appengine.ext import db

class DocFile(db.Model):
    doc_name = db.StringProperty()
    doc_file = db.BlobProperty()

q = db.GqlQuery("SELECT * FROM DocFile WHERE doc_name = :1", myname)
results = q.fetch(1)
if results:
    doc = results[0]
    mail.send_mail(sender="[email protected]",
                  to="Albert Johnson <[email protected]>",
                  subject="The doc you requested",
                  body="""
Attached is the document file you requested.

The example.com Team
""",
                  attachments=[(doc.doc_name, doc.doc_file)])

As a security measure to protect against viruses, you cannot send email attachments—or zip files—containing any of the following extensions:

  • ade
  • adp
  • bat
  • chm
  • cmd
  • com
  • cpl
  • exe
  • hta
  • ins
  • isp
  • jse
  • lib
  • mde
  • msc
  • msp
  • mst
  • pif
  • scr
  • sct
  • shb
  • sys
  • vb
  • vbe
  • vbs
  • vxd
  • wsc
  • wsf
  • wsh

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.