- Gmail API Users.drafts
- Multipurpose Internet Mail Extensions PART#1
- Multipurpose Internet Mail Extensions PART#2
- Media Types
- The contentType is now "message/rfc822" instead of "application/json" thanks Tholle from
SO
Copy Message.gs to your project. You have to enable advanced services for Gmail API.
Be sure your project has next files:
- quoted-printable.js. Rename to
gs
. - utf8.js. Rename to
gs
.
Clone
git clone https://gist.github.com/7e96514c3cb3075dde02.git
For biulds you have to have git & node & npm. Then you can
git clone https://gist.github.com/7e96514c3cb3075dde02.git && npm install
It's strange but it can be.
For the tests you need to connect the TestApp Library
var msg = new Message();
msg.to = '[email protected]';
msg.body = '<h1>TEST</h1>';
msg.subject = 'TEST';
var file = DriveApp.createFile('~myfile.txt', 'content' + new Date(), 'text/plain');
msg.attachments = [file];
msg.createDraft();
msg.attachments = [File, File];
File
is a file in Google Drive. Files can be accessed or created from DriveApp.
var file = DriveApp.getFileById(id);
msg.attachments = [file];
var filesi = DriveApp.getFolderById(id).getFilesByType('text/plain');
var files = [];
while(filesi.hasNext()){
files.push(filesi.next());
}
msg.attachments = files;
...
var thread = Gmail.Users.Threads.list('me').threads[0].id;
msg.threadId = thread;
var resp = msg.createDraft();
@jief666
You have to find
threadId
of the thread then push it intomessage
asmessage.threadId = thread;
Look at Create as a thread's child