Created
February 19, 2016 14:38
-
-
Save erickoledadevrel/79ee7799485bec141ee4 to your computer and use it in GitHub Desktop.
Create a Google Calendar event with an attachment in Apps Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); | |
} |
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
i have a problem with this,
in line 22 i get the following error: GoogleJsonResponseException: API call to calendar.events.insert failed with error:.
any input on what that could be? i've no clue honestly