我正在编写一个脚本,用于读取和处理在我的电子邮件帐户上收到的日历邀请。
问题是:
//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();
attachments = 0,表示虽然gmail过滤器认为日历邀请是附件并正确过滤,但Google Apps脚本显然不会将日历邀请视为附件。
如何以编程方式阅读具有日历邀请的电子邮件?
最佳,
OP
答案 0 :(得分:0)
使用Apps脚本将日历邀请作为附件获取是没有问题的。你的代码:
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);
}
记录附件没有问题,我可以将数据检索为字符串。这对我使用Gmails本机日历和从其他邮件系统搜索邀请时起作用。