Skip to content

Instantly share code, notes, and snippets.

@erickoledadevrel
Created February 19, 2016 14:38
Show Gist options
  • Save erickoledadevrel/79ee7799485bec141ee4 to your computer and use it in GitHub Desktop.
Save erickoledadevrel/79ee7799485bec141ee4 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
});
}
@erickoledadevrel
Copy link
Author

Make you you've enabled the Calendar advanced service and have toggled it on in your Cloud project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment