Reputation: 31
The Google Apps script ran in a spreadsheet below and everything worked fine except sending the invites. Using sendInvites:true
the event is created in the calendar and the guests are added but no email is sent. I have tried it without using the var advancedArgs
and same results.
if (eventImported != EVENT_IMPORTED && title != "") { // Prevents importing duplicates
var cal = CalendarApp.openByName('calendarname');
var advancedArgs = {description: details, location: cust, guests:guestlist, sendInvites:true};
cal.createEvent("10% Complete-->"+title, startDate, endDate, {description: details, location: cust, guests:guestlist, sendInvites:true});
sheet.getRange(startcolumn + i, 9).setValue(EVENT_IMPORTED);
Upvotes: 3
Views: 4092
Reputation: 10710
I found out that no event invitation is sent to my own email address (although the event is added to my calendar). But event invitations are correctly sent to other guests.
Upvotes: 0
Reputation: 23
I suspect you may be being rate limited somewhere. I had a similar problem and sending emails would work sporadically. I was polling a group of users calendars and when I found enough available at a certain time I would send the invitation to all.
In frustration I added:
Utilities.sleep(30000);
just before I create the event and it works reliably now. You can probably get away with less time, but mine runs on trigger at 2am so I don't care.
Upvotes: 0
Reputation: 46822
The error must be somewhere else, I tested your code in this simplified version and I received the invitation as expected. (I use this option a lot in many scripts without any issue)
Could you show how you get your guest list ? is it a comma separated email list as specified in the documentation ?
function testcal(){
var cal = CalendarApp.getDefaultCalendar()
var advancedArgs = {description: 'details', location: 'here', guests:'[email protected]', sendInvites:true};// change the email adress to a valid one that you have access to (but not your email adress of course !
var startDate = new Date();// now
var endDate = new Date(startDate.setHours(10));// at 10 AM, change this according to time of the day when you (eventually) test it
cal.createEvent("test to delete", startDate, endDate, advancedArgs);
}
Upvotes: 2
Reputation: 1
Try Out: var advancedArgs = {description: details, location: cust, guests:guestlist, sendInvites:"TRUE"};
Upvotes: -1