创建文档并以PDF格式发送电子邮件 [英] Create document and email as a PDF
问题描述
我正在尝试创建每日概述文档,我每天早晨都可以通过发送到电子邮件中的PDF来阅读该文档.我有一个脚本可以创建Google文档,但是每当我尝试将其以PDF格式通过电子邮件发送时,它都会发送一个完全空白的文档.当我检查Google文档(我目前也正在通过电子邮件发送以帮助测试错误)时,它会显示我想要的内容.这就是我用来创建PDF的内容:
I am trying to create a Daily Overview document that I can read each morning by way of a PDF delivered to my email. I have a script that creates a Google Doc but whenever I try to email it as a PDF it sends a completely blank document. When I check the Google doc (which I am currently also emailing to help test for bugs) it shows what I want. This is what I am using to create the PDF:
var pdfDocument = DriveApp.getFileById(ID).getAs("application/pdf");
当我将"ID"替换为从现有文档复制的字符串ID时,此部分有效.变量"ID"定义为:
This part works when I replace 'ID' with a string ID copied from an already existing doc. The variable 'ID' is defined as:
var ID = doc.getId();
我知道这是在提取正确的ID,因为我已将记录器设置为显示它,并且它与生成的Google文档匹配.我是脚本新手,所以请原谅任何错误或礼节欠佳. 此处是指向脚本的链接.
I know this is pulling the correct ID because I have the logger set to display it and it matches the resulting Google Doc. I am new to scripting so forgive any mistakes or poor etiquette. Here is a link to the script.
推荐答案
好吧,我是个猎人.我在与Google文档相关的所有内容的末尾添加了doc.saveAndClose();
,但是在将文档转换为PDF之前.希望这对其他人有帮助!
Well, I was a nimrod. I added doc.saveAndClose();
at the end of everything to do with the Google Doc but before getting the document as a PDF. Hope this helps someone else!
这篇关于创建文档并以PDF格式发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!