Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Appengine(Python)中将PDF附加到电子邮件_Python_Google App Engine - Fatal编程技术网

在Appengine(Python)中将PDF附加到电子邮件

在Appengine(Python)中将PDF附加到电子邮件,python,google-app-engine,Python,Google App Engine,如何将Appengine应用程序基本目录中的PDF附加到电子邮件? message.attachments应该是什么样子?根据,attachments字段是元组列表,其中第一个元素是文件名,第二个元素是表示文件的字节字符串。因此,您只需阅读pdf: pdf_contents = open(os.path.join(os.path.dirname(__file__), 'yourpdf.pdf')).read() 这假设您的pdf和python文件位于同一文件夹中。然后 attachments

如何将Appengine应用程序基本目录中的PDF附加到电子邮件?
message.attachments应该是什么样子?

根据,attachments字段是元组列表,其中第一个元素是文件名,第二个元素是表示文件的字节字符串。因此,您只需阅读pdf:

pdf_contents = open(os.path.join(os.path.dirname(__file__), 'yourpdf.pdf')).read()
这假设您的pdf和python文件位于同一文件夹中。然后

attachments = [('yourpdf.pdf', pdf_contents)]