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