Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Google apps script 正在读取收到的日历邀请的内容_Google Apps Script - Fatal编程技术网

Google apps script 正在读取收到的日历邀请的内容

Google apps script 正在读取收到的日历邀请的内容,google-apps-script,Google Apps Script,我正在编写一个脚本,用于读取和处理电子邮件帐户上收到的日历邀请 问题是: //there is only one message that is the result of this filter, and it contains a calendar invite var threads = GmailApp.search('is:unread from:xxx@yyy.com has:attachment',0,10); var msgs = GmailApp.getMessagesForT

我正在编写一个脚本,用于读取和处理电子邮件帐户上收到的日历邀请

问题是:

//there is only one message that is the result of this filter, and it contains a calendar invite
var threads = GmailApp.search('is:unread from:xxx@yyy.com has:attachment',0,10);
var msgs = GmailApp.getMessagesForThreads(threads);
var attachments = msgs[0][0].getAttachments();

附件=0,这意味着Gmail过滤器认为日历邀请是附件并正确过滤,谷歌应用程序脚本显然不考虑日历邀请作为附件。 如何以编程方式读取包含日历邀请的电子邮件

最好的


OP

我可以使用应用程序脚本将日历邀请作为附件获取。您的代码:

function getCalAttach() { 
   var threads = GmailApp.search('is:unread from:s@steve.thevoxbox.info has:attachment',0,10);
   var msgs = GmailApp.getMessagesForThreads(threads);
   var attachments = msgs[0][0].getAttachments();
   var readAtt = attachments[0].getDataAsString();
   Logger.log(readAtt);
}
记录附件没有问题,我可以以字符串的形式检索数据。这对我使用Gmail本机日历和搜索其他邮件系统的邀请都有效


谷歌的Calandar邀请与outlook不同。Outlook邀请在结构上有所不同,具体取决于它们通过的exchange服务器。那只是两个系统。;谢谢你的洞察力!解析和处理不同格式的邀请应该没有问题,但我无法在应用程序脚本中读取邀请。重点是很难定义可靠的搜索条件来获取邀请,这就是为什么在担心解析之前这很重要。并非所有人都有附件。许多是作为多部分发送的。或者您的问题是关于已知的一致源的?至少有一个通过MS-Exchange服务器发出的Microsoft Outlook邀请没有使用您或我的代码显示。真奇怪。我会给你发一个邀请,看看你是否得到同样的结果。我还将探索在google apps脚本中使用google calendar v3 api,看看是否可以使用该api获取最新的日历条目google apps scripts calendar对象显然不允许我这样做。我提到了这种可能性。我自己也经历过这样的痛苦:有时候日历邀请包含在base64编码的多部分消息中——你不需要做太多的工作来找到它们。所以我改变了策略,现在我使用Google解析邀请,我使用日历API读取我需要的数据。仍然很难以我需要的方式获取数据示例:无法按最近编辑或创建的事件排序,但这是一个进步