Skip to content

Instantly share code, notes, and snippets.

@lordlycastle
Forked from erickoledadevrel/Code.gs
Created April 12, 2021 20:50
Show Gist options
  • Save lordlycastle/95c36c9f1150b136ed92630b04507cb2 to your computer and use it in GitHub Desktop.
Save lordlycastle/95c36c9f1150b136ed92630b04507cb2 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