Skip to content

Instantly share code, notes, and snippets.

@printminion
Forked from erickoledadevrel/Code.gs
Created February 19, 2016 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save printminion/96b59781c1e3506bff4a to your computer and use it in GitHub Desktop.
Save printminion/96b59781c1e3506bff4a to your computer and use it in GitHub Desktop.
Create a Google Calendar event with an attachment in Apps Script
function createEventWithAttachment() {
var driveFileId = '...';
var file = DriveApp.getFileById(driveFileId);
var event = {
summary: 'Test Event with Attachments',
description: 'Woot!',
attachments: [{
fileId: driveFileId,
fileUrl: file.getUrl(),
mimeType: file.getMimeType(),
title: file.getName()
}],
start: {
dateTime: '2016-02-18T17:00:00',
timeZone: 'America/New_York'
},
end: {
dateTime: '2016-02-18T18:00:00',
timeZone: 'America/New_York'
}
};
Calendar.Events.insert(event, 'primary', {
supportsAttachments: true
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment