4
如何使用谷歌应用程序引擎(Python)将位于Web URL上的文件附加到电子邮件?将文件附加到App Engine中的电子邮件中?
我有位于发言权文件:http://www.abc.com/files/file.pdf
我想这个附加到电子邮件并将其发送给用户在App Engine上。我该怎么做呢?
如何使用谷歌应用程序引擎(Python)将位于Web URL上的文件附加到电子邮件?将文件附加到App Engine中的电子邮件中?
我有位于发言权文件:http://www.abc.com/files/file.pdf
我想这个附加到电子邮件并将其发送给用户在App Engine上。我该怎么做呢?
要发送附件,您必须填写包含文件名和文件内容的二值元组列表的电子邮件附件字段。来自here
from google.appengine.api import urlfetch
from google.appengine.api import mail
url = "http://www.abc.com/files/file.pdf"
result = urlfetch.fetch(url)
if result.status_code == 200:
document = result.content
mail.send_mail(sender="[email protected]",
to="[email protected]",
subject="The file you wanted",
body="Here is the file you wanted",
attachments=[("The file name.pdf", document)])
谢谢!完美地工作! – demos 2010-08-03 18:06:05