iEhohs DokuWiki

プログラミングや設定方法など、個人的なナレッジを残しておくWikiです。

ユーザ用ツール

サイト用ツール


gws:gas-gmail-create-draft

Gmailの下書きを作成するGAS

let recipient = 'hoge@example.com';
let subject = '件名';
let body = '本文';
let attachmentsFile = DriveApp.getFileById(****************).getBlob();
let options = {
    'attachments': attachmentsFile
};
let mailId = GmailApp.createDraft(recipient,subject,body,options).getId();

フォルダ内のファイルを添付する場合

let files = attachmentFolder.getFiles();
let attachmentFiles = new Array()
//各ファイルごとにBlob型を取得
while(files.hasNext()){    
    let file = files.next();
    attachmentFiles.push(file.getBlob());
}
let options ={
    'attachments': attachmentFiles,
};
GmailApp.createDraft(recipient,subject,body,options).getId();
スポンサーリンク
gws/gas-gmail-create-draft.txt · 最終更新: 2024/07/26 20:24 by shimehitsu14