[英]Attach a pdf from google drive to an email using google apps script
I'm using a custom created google apps script to send out some emails. 我正在使用自定义创建的Google Apps脚本发送一些电子邮件。 I have a PDF in my google drive that I am trying to attach to an email but it is not working.
我的Google驱动器中有一个PDF,我尝试将其附加到电子邮件中,但不起作用。 I keep on getting the error "Document is missing (perhaps it was deleted?)"
我不断收到错误消息“文档丢失(也许它已被删除?)”
Here is my full code... 这是我的完整代码...
function sendDetails(e) {
var itemURL = 'https://docs.google.com/file/d/0Bw7JWLKeRBKASUFldGM1RTRIaFE/edit';
var docName = DocumentApp.openByUrl(itemURL).getName();
}
Note that the above PDF is a publicly accessible PDF file that anyone can get to. 请注意,以上PDF是任何人都可以访问的可公开访问的PDF文件。 I know it exists but it's not allowing me to access it.
我知道它存在,但是不允许我访问它。 All that I am trying to do is take the file and attach it to an email.
我要做的就是拿走文件并将其附加到电子邮件中。 There is obviously more to my code than the about but I trimmed down just to that to try to narrow the error and no such luck.
我的代码显然比“ about”更多,但我只是为了缩小错误而进行了精简,没有运气。 Any help would be greatly appreciated.
任何帮助将不胜感激。
DocumentApp deals with Google Documents - Google's WordPad-like editor. DocumentApp处理Google Documents(类似于WordPad的Google编辑器)。 Since the file in question is a PDF, it's not available to DocumentApp.
由于相关文件为PDF,因此DocumentApp无法使用。
Instead, you should be using DriveApp . 相反,您应该使用DriveApp 。 Additionally, since there is no DriveApp method to open a file by URL, you need to use DriveApp.getFileById() .
此外,由于没有通过URL打开文件的DriveApp方法,因此需要使用DriveApp.getFileById() 。 (The ID is
"0Bw7JWLKeRBKASUFldGM1RTRIaFE"
in your example.) (在您的示例中,该ID为
"0Bw7JWLKeRBKASUFldGM1RTRIaFE"
。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.