Google apps script 需要帮助为SpreadsheetApp创建GMAIL发布/订阅通知服务(Google Appscript)

Google apps script 需要帮助为SpreadsheetApp创建GMAIL发布/订阅通知服务(Google Appscript),google-apps-script,google-cloud-pubsub,Google Apps Script,Google Cloud Pubsub,我希望我不必重复这个问题,但我的老板把这个问题推到了最优先的位置,我需要帮助来解决这个问题。我正在尝试使用GAS脚本从我的GSuite域上的地址中提取发布/订阅通知(目前,我正在测试我的)。基本上,我试图完成所有这些材料中描述的内容: 我已经在Google Drive的我的工作域上创建了参考文献1中记录的GAS项目,作为草稿发布到chrome store,添加了发布/订阅API和库,连接到发布/订阅云服务,并拥有Gmail服务帐户的权限,并创建了必要的主题/订阅。我已运行Enrollm

我希望我不必重复这个问题,但我的老板把这个问题推到了最优先的位置,我需要帮助来解决这个问题。我正在尝试使用GAS脚本从我的GSuite域上的地址中提取发布/订阅通知(目前,我正在测试我的)。基本上,我试图完成所有这些材料中描述的内容:

我已经在Google Drive的我的工作域上创建了参考文献1中记录的GAS项目,作为草稿发布到chrome store,添加了发布/订阅API和库,连接到发布/订阅云服务,并拥有Gmail服务帐户的权限,并创建了必要的主题/订阅。我已运行Enrollmail并返回了一个有效的历史记录Id,我可以使用API资源管理器查找该Id,并确认该文件可以写入驱动器上指定的电子表格。但是doPost方法从未像我希望的那样触发事件在电子表格上写入。有人能帮我找出为什么这个代码在我的域上不起作用吗?我没有明确的错误消息,因为我正在尝试运行post服务

这是我的密码:

函数doPost(e){
var ss=SpreadsheetApp.open(DriveApp.getFilesByName('eption_Log').next()).getSheets()[0];
ss.appendRow(['Push was received'+new Date()]);
试一试{
var message=JSON.parse(e.postData.getDataAsString()).message;
var data=Utilities.newBlob(Utilities.base64Decode(message.data)).getDataAsString();
ss.appendRow([new Date(),message.message_id,data]);
}
catch(e){ss.appendRow(['failure',e]);}
返回200;
}
函数注册电子邮件(){
var EMAIL=Session.getActiveUser().toString();
var watchRes=Gmail.newWatchRequest();
watchRes.labelIds=[“收件箱”];
watchRes.labelFilterAction='include';
watchRes.topicName='projects/project-id-3596301251382091354/topics/eWarning';
var response=Gmail.Users.watch(watchRes,EMAIL);
Logger.log(响应);
var ss=SpreadsheetApp.open(DriveApp.getFilesByName('eption_Log').next()).getSheets()[0];
ss.appendRow(['Manual Test']);//这很有效
}
函数checkHistory(){
var EMAIL=Session.getActiveUser().toString();
Logger.log(Gmail.Users.History.list(电子邮件,{startHistoryId:'***'}));//使用有效的ID

}
对于像我这样需要在Google Appscript中创建监控服务并需要快速操作的人,我想出了一个快速脚本,只需按特定标签检查电子邮件即可。使用GmailApp,您也可以按主题检查消息。代码如下:

var EMAILID=Session.getActiveUser().getEmail();
函数getMessages(){
var expLabel=GmailApp.getUserLabelByName(“情节到期”);
var threads=expLabel.getThreads();
对于(var t=0;t0)/)
{
var startInd=email.body.indexOf('Start')+12;
var endInd=email.body.indexOf('End')+12;
var pasInd=email.body.indexOf('Number')+8;
var qualInd=email.subject.indexOf('Q');
var qualco=email.subject.substring(qualInd,qualInd+17);
var warning=email.body.substring(email.body.indexOf('eposit Expires in')、email.body.indexOf('days')+4);
var startDate=email.body.substring(startInd,startInd+12);
var endDate=email.body.substring(endInd,endInd+11);
var priorauthname=email.body.substring(pasInd,pasInd+13);
var ss=SpreadsheetApp.openById('mysheetID').getSheets()[0];
ss.appendRow([qualco,priorAuthNumber,startDate,endDate,warning]);
}
消息[m].moveToTrash();
}
}

}
我不知道你是否还在检查老问题,但关于这个家伙,你提到这是你的解决办法。此设置是否用于应用程序打开时的扫描?或者这是煤气版的酒吧/酒吧?