Google App 脚本在将解压缩的 CSV 附加到 Google 表格之前解压缩 Gmail 附件
我对 Google App Script 完全陌生。我正在尝试构建一些东西,因为我找不到完全符合我想要的功能的 Google 插件。但我不知道我在做什么!有人愿意帮忙吗?
目标:我需要一个脚本来识别来自特定发件人的具有特定主题行的每日电子邮件何时到达我的 Gmail 收件箱。电子邮件始终带有 .zip 附件。我需要脚本来 1) 解压附件 - 这会给我一个 csv 文件,然后我需要 2) 将解压的 csv 文件附加到 Google 表格中。
这是我从别人的脚本开始的地方:
function importDailyCallVolumes() {
// Get the newest Gmail thread based on sender and subject
var gmailThread = GmailApp.search("from:[email protected] subject:\"Daily Call Vols\"", 0, 1)[0];
// Get the attachments of the latest mail in the thread.
var attachments = gmailThread.getMessages()[gmailThread.getMessageCount() - 1].getAttachments();
// Here I need to add some code to unzip the attachment - how?
// Get and and parse the CSV from the unzipped attachment
var csv = Utilities.parseCsv(attachments[0].getDataAsString());
return csv;
}
非常感谢任何愿意帮助应用程序脚本新手的人!
I am completely new to Google App Script. I'm trying to build something because I can't find a Google add-on that does exactly what I want. But I have no idea what I'm doing! Is anyone willing to help?
Goal: I need a script that will identify when a daily email with a particular subject line and from a particular sender arrives in my gmail inbox. The email always has a .zip attachement. I need the script to 1) unzip the attached - which gives me a csv file, and then I need 2) the unzipped csv file to be appended to a Google Sheet.
Here is where I am starting with someone else's script:
function importDailyCallVolumes() {
// Get the newest Gmail thread based on sender and subject
var gmailThread = GmailApp.search("from:[email protected] subject:\"Daily Call Vols\"", 0, 1)[0];
// Get the attachments of the latest mail in the thread.
var attachments = gmailThread.getMessages()[gmailThread.getMessageCount() - 1].getAttachments();
// Here I need to add some code to unzip the attachment - how?
// Get and and parse the CSV from the unzipped attachment
var csv = Utilities.parseCsv(attachments[0].getDataAsString());
return csv;
}
Thank you so much to anyone willing to help an App Script newbie!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 CSV 压缩文件附加到活动工作表
Utilities.parseCsv( )
Append CSV zipped file to Active sheet
Utilities.parseCsv()