I have the following code and attendees are not able to receive emails about the event. Though the event is reflecting in their calendar.
var options = {
description: description,
location: location,
guests: email_address,
sendInvites: true
}
var event = CalendarApp.getCalendarById(calendarId).createEvent(title,
start_datetime, end_datetime,
options);
I have added oauthScopes to appsscript.json as well.
"oauthScopes": [
"https://www.googleapis.com/auth/calendar",
"https://www.google.com/calendar/feeds"
]
It seems like an authorization issue but not sure how to solve this.
You don't need to manually add any scopes while running the script from the browser editor.
Your code worked perfectly for me:) I added a few variables to complete it but it worked just fine -
function myFunction() {
var calendarId = 'self@gmail.com'; // if using your own or default calendar ID
var description = 'test desc';
// ref link - https://developers.google.com/apps-script/reference/calendar/calendar-app#advanced-parameters_4
var email_address = 'contact1@gmail.com, contact2@gmail.com';
// comma separated guest list
var title = 'test title';
var start_datetime = new Date();
var end_datetime = new Date();
var options = {
description: description,
guests: email_address,
sendInvites: true
}
var event = CalendarApp
.getCalendarById(calendarId)
.createEvent(title, start_datetime, end_datetime, options);
}
My default manifest file looks like this -
{
"timeZone": "Asia/Kolkata",
"dependencies": {
},
"exceptionLogging": "STACKDRIVER"
}
No additional scopes seem to have been added. However, when I view my File > Project properties > Scope , only a single scope seem to have been added by the script -
OAuth Scope required by script:
https://www.googleapis.com/auth/calendar
Hope this helps.
Edit note: Forgot to add -
Email notifications are being received as well
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.