通过脚本共享Google工作表

时间:2018-11-16 01:11:27

标签: google-apps-script google-sheets google-sheets-api google-apps-script-editor

我希望在脚本中通过电子邮件共享Google工作表。此代码正确创建了电子邮件草稿,并在工作表中插入了超链接。当您将其作为驱动器链接插入GMAIL时,我希望它看起来像它。

Here is a sample of what it looks like when you insert as a drive link

代码

function getSheetId() {
    return SpreadsheetApp.getActiveSheet().getSheetId().toString();
};
function getSheetUrl() {
   var SS = SpreadsheetApp.getActiveSpreadsheet();
   var ss = SS.getActiveSheet();
   var url = '';
   url += SS.getUrl();
   url += '#gid=';
   url += ss.getSheetId(); 
   return url;
  }

 function notDumb(){
   var body = getSheetUrl();
   var options = {}
   options.htmlBody ='<a href=\"' +body+ '">Here is the File</a>';
   GmailApp.createDraft("john@john.com", "Testing",'', options); 

 }

0 个答案:

没有答案