我经常在手机上放一些东西,我想留待以后参考。也许是一张照片或一篇有趣的文章链接,以便稍后在电脑上阅读。
如何通过手机上的电子邮件保存此信息,以便使用Google AppsScript将电子邮件内容存储在Google协作平台页面中
答案 0 :(得分:0)
此应用脚本代码有效。让它在计时器上触发(例如每5分钟一次),并且在主题中使用 emailarch 发送到您的Gmail帐户的任何电子邮件都将作为包含附件的子页面添加到页面中。父页面列表将更新。
“网站”页面应为“列表”类型,其中包含两个文本列“日期和项目”。
/**
*/
function createEmailArch() {
var site = 'YOURSITE';
var page_name = 'APAGEINYOURSITE';
var site_url = 'https://sites.google.com/site/'+site+'/'+page_name;
var site = SitesApp.getSite(site);
var page = site.getChildByName(page_name);
var curr_date = new Date();
var curr_date_fmt = Utilities.formatDate(curr_date,'Australia/Melbourne','yyyy-MM-dd HH:mm:ss');
var threads = GmailApp.search('subject:"emailarch" is:unread');
for ( var j = 0 ; j<threads.length;j++) {
var messages = threads[j].getMessages();
for ( var i = 0 ; i < messages.length; i++ ) {
var message = messages[i];
var subj = message.getSubject();
var body = message.getBody();
var mdte = message.getDate();
var mfrm = message.getFrom();
var meto = message.getTo();
var atta = message.getAttachments();
var cont = "Subject : "+subj+"<br/>"+
"To : "+meto+"<br/>"+
"From : "+mfrm+"<br/>"+
"Date : "+mdte+"<br/>"+
body;
var dte2 = Utilities.formatDate(curr_date,"Australia/Melbourne","yyyy_MM_dd_HH_mm_ss")+"_"+j+"_"+i;
for ( var k=0;k<atta.length;k++) {
var iname = atta[k].getName();
if ( atta[k].getContentType().indexOf('image')>=0 ) { // If attachment is an image show inline
cont = cont +"<hr/>"+
"<div style='display:block;text-align:left'>"+
"<a href='"+site_url+"/"+dte2+"/"+iname+"?attredirects=0' imageanchor='1'>"+
"<img src='"+site_url+"/"+dte2+"/"+iname+"?height=400&width=224' border='0' height='400' width='224'>"+
"</a></div><br/>";
}
}
var p = page.createWebPage(curr_date_fmt,dte2,cont);
for ( var k=0;k<atta.length;k++) {
p.addHostedAttachment(atta[k]);
}
page.addListItem( [curr_date_fmt, "<a href='"+site_url+"/"+dte2+"'>"+subj+"</a>"]);
message.markRead();
}
}
};