Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 使用应用程序脚本创建图像;“发送到驱动器”;_Google Apps Script - Fatal编程技术网

Google apps script 使用应用程序脚本创建图像;“发送到驱动器”;

Google apps script 使用应用程序脚本创建图像;“发送到驱动器”;,google-apps-script,Google Apps Script,大家好,我正在使用发送到驱动应用程序脚本 现在,如果我收到的电子邮件包含一个作为附件的图像,该图像将存储在我指定的文件夹中,但我尝试打开它时无法看到预览 相反,如果我在Google Drive中手动上传图像,我可以看到预览 我注意到,从应用程序脚本创建的图像的URL的id比手动上传的其他图像的id长 我看不到的图像id示例(由应用程序脚本创建): 我可以看到的图像id示例(手动上载) 如何修改脚本来解决此问题 先谢谢你 var threads = GmailApp.getUserLabelB

大家好,我正在使用发送到驱动应用程序脚本

现在,如果我收到的电子邮件包含一个作为附件的图像,该图像将存储在我指定的文件夹中,但我尝试打开它时无法看到预览

相反,如果我在Google Drive中手动上传图像,我可以看到预览

我注意到,从应用程序脚本创建的图像的URL的id比手动上传的其他图像的id长

我看不到的图像id示例(由应用程序脚本创建):

我可以看到的图像id示例(手动上载)

如何修改脚本来解决此问题

先谢谢你

var threads = GmailApp.getUserLabelByName(gLabel).getThreads(0, 5);

  var folder  = DocsList.getFolder(gFolder);

  for (var x=0; x<threads.length; x++) {

    var messages = threads[x].getMessages();

    for (var y=0; y<messages.length; y++) {

      var att = messages[y].getAttachments();


      for (var z=0; z<att.length; z++) {
        try {

        Logger.log(att[z].getContentType());

          var file = folder.createFile(att[z]);
          Utilities.sleep(1000);
        }
        catch (e) {
          GmailApp.sendEmail(
            Session.getActiveUser().getUserLoginId(), 
            "Error: " + e.message
          );
        }
      }       
    }    
    GmailApp.getUserLabelByName(gLabel)
      .removeFromThread(threads[x]);
  }
var threads=GmailApp.getUserLabelByName(gLabel.getThreads)(0,5);
var folder=DocsList.getFolder(gFolder);

对于(var x=0;x我认为这可能与问题有关

我可以使用createFile和copy方法在DocList中复制此文件:

  //Using uploaded jpeg as source
    var doc =  DocsList.getFileById(id)
        DocsList.copy(doc,"test1");

副本将加载,没有预览可用

我只能确认这一点…希望有人有想法,否则您可以提出