Why not google apps script sending invitations

Google Apps script works in the spreadsheet below and everything works fine except for sending invitations. Using sendInvites:true

, an event is created on the calendar and guests are added but no email is sent. I tried this without using var advancedArgs

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

      

+3


source to share


4 answers


The error must be somewhere else, I checked your code in this simplified version and I got the prompt as expected. (I use this option in many scenarios without any problem)

Could you show me how you get your guest list? is it a comma separated list of email addresses as stated 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);
    }

      

+2


source


I suspect you may be limited in speed. I had a similar problem and sending emails would work sporadically. I tried a group of users calendars and when I found enough available at a specific time, I would send an invite to everyone.

In desperation, I added:



Utilities.sleep (30,000);

just before the event is created and it now works reliably. You can probably get away with less time, but mine runs on a trigger at 2am so I don't care.

0


source


I found out that the invitation is not sent to my own email (although the event is added to my calendar). But event invitations are correctly sent to other guests.

0


source


Try: var advancedArgs = {description: details, location: cust, guests: guest list, sendInvites: "TRUE"};

-1


source







All Articles