简体   繁体   中英

why isn't google apps script sending invitations

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);

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:'serge@xxx.com', 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);
    }

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.

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.

试用:var advancedArgs = {description: details, location: cust, guest:guestlist, sendInvites:"TRUE"};

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM