Cannot fetch shared google drive link (anyone) using apps script UrlFetchApp

狂风中的少年 提交于 2019-12-23 03:23:54

问题


I am able to fetch and email the img2 but when I tried a shared-with-everyone image the below failsvand the email shows only empty box. What is gong on? TIA.

    function sendEmail() {
//      var img2 = "https://upload.wikimedia.org/wikipedia/commons/3/38/JPEG_example_JPG_RIP_001.jpg"
      var img = "https://drive.google.com/open?id=19JSe5jLnlllnUoYZlimeWAC39qLXwWs-"
        var subject = "Subject";
        var msgBody = "Body";    
        var imgFetch = UrlFetchApp
        .fetch(img2)
        .getBlob()
        .setName("imgFetch");

        msgBody = "<img src='cid:thisImg' style='width:100px; height:70px;' />";

        MailApp.sendEmail(mail, subject, "",
                          { htmlBody: msgBody + "<BR/><BR/>",
                           inlineImages:
                           {
                           thisImg: imgFetch,                   
                          }
                          }); 
    }

回答1:


How about this modification? In this modification, the endpoint was modified.

From:

var img = "https://drive.google.com/open?id=19JSe5jLnlllnUoYZlimeWAC39qLXwWs-"

To:

var img = "https://drive.google.com/uc?id=19JSe5jLnlllnUoYZlimeWAC39qLXwWs-"


来源:https://stackoverflow.com/questions/55754450/cannot-fetch-shared-google-drive-link-anyone-using-apps-script-urlfetchapp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!