google-apps-script - 如何阅读 gmail 邮件内容并仅搜索链接,然后将其保存在某处
问题描述
我想编写一个脚本,它读取电子邮件内容,其中将包含一些图像的链接。是否有脚本可以读取消息内容并将此链接保存到 txt 将在 google 驱动器上?
现在我有这个,它以某种方式工作,但会生成 2 个文件。
function test()
{
var BouncedEmails = GmailApp.search("label:Inbox .png ");
for( var i=0;i<BouncedEmails.length;i++)
{
var Gmessage = GmailApp.getMessagesForThread(BouncedEmails[i]);
for(var j=0;j<Gmessage.length;j++)
{
var body = Gmessage[j].getPlainBody();
var fileName,newFile; //Declare variable names
fileName = "Export" + new Date().toString().slice(0,24) + ".txt";//Create a new file name with date on end
newFile = DriveApp.createFile(fileName,body);
}
}
}
解决方案
当前脚本生成一个 txt 文件到 Google Drive,其中包含:
https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png 一些东西 https://i.redd.it/9xzdfgdfg8o21.jpg 一些东西 https://i.redd.it/9xwer2342dd8o21.jpg
脚本生成文件的邮件: 示例
推荐阅读
- matlab - 如何在 foo 循环中创建图形?
- python - 使用python在csv中存储带有列表值的字典
- google-bigquery - 将数据流式传输到 bigquery 仅返回部分数据
- javascript - jQuery to filter elements with class names based on selected value
- java - Java 正则表达式 - 即使不存在匹配项,也会返回匹配项的负前瞻
- cytoscape.js - 在 Cytoscape.js 节点中包含长文本
- html - 字体真棒 5 svg 图标和文本在顶部垂直对齐
- django - 如何在 Djoser 中禁用用户名更改?
- javascript - 如何根据 Material-icons 名称查找元素?
- gcc - Boehm-Demers-Weiser 垃圾收集器未找到 lgc