我正在尝试使用谷歌应用程序脚本来检索电子邮件附件,下面是我的代码来检查电子邮件中是否有任何附件
function testMail() {
var threads = GmailApp.getInboxThreads();
for (var i = 0; i < 10; i++) {
var mess=threads[i].getMessages()[0];
if (mess.getAttachments().length>0)
{
//var filename=mess.getAttachments()[0].
Logger.log(mess.getSubject());
Logger.log(mess.getAttachments()[0].getName());
var conn = Jdbc.getConnection("jdbc:oracle:thin:@xxx.xxx.xxx.xxx/xxx.xxx.xxx", "xxx","xxxxxxx");
conn.setAutoCommit(false);
var stmt = conn.prepareStatement("insert into blob_table (filnname,blob_field) values (?,?)");
stmt.setString(1, mess.getAttachments()[0].getName());
stmt.setBlob(2, mess.getAttachments()[0]);
var res = stmt.execute();
conn.commit();
conn.close();
break;
}
}
}
但是当我运行脚本时出现错误“找不到方法setBlob提示”,如果我只插入字段文件名,我可以将数据保存到表blob_table,有没有什么特殊的方法可以插入blob?
谢谢