title: How do I send the standard invitation email when calling addGuest on a CalendarEvent?
body: <p>Whenever I add a guest via the Google Calendar UI, the following dialog pops up:</p>
  
  <blockquote>
    <p><a href="https://i.stack.imgur.com/W3KTN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W3KTN.png" alt="enter image description here"></a></p>
  </blockquote>
  
  <p>If I choose "Send" it sends a nicely formatted email to the user with an option to respond to the calendar event too:</p>
  
  <blockquote>
    <p><a href="https://i.stack.imgur.com/E8172.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E8172.png" alt="enter image description here"></a></p>
  </blockquote>
  
  <p>This works flawlessly when you're manually using the Google Calendar UI. Problem is I'm trying to use Google Apps Scripts to automate adding people to events.</p>
  
  <p>I'm programmatically adding guests to a CalendarEvent by using <a href="https://developers.google.com/apps-script/reference/calendar/calendar-event#addGuest(String)" rel="nofollow noreferrer">addGuest()</a>:</p>
  
  <pre><code>event.addGuest("user@example.com");
  </code></pre>
  
  <p>However, there doesn't seem to be an option to send an email.</p>
  
  <p>The closest I could find is that when you <a href="https://developers.google.com/apps-script/reference/calendar/calendar#createEvent(String,Date,Date,Object)" rel="nofollow noreferrer">programmatically create an event</a>, you can set <code>sendInvites</code>:</p>
  
  <pre><code>  var event = CalendarApp.getDefaultCalendar().createEvent(
      'Test',
      new Date('April 5, 2029 20:00:00 UTC'),
      new Date('April 5, 2029 21:00:00 UTC'),
      {sendInvites: true, guests:"your.email+1@example.com"});
    Logger.log(event.getId());
  </code></pre>
  
  <p>This sends a nicely formatted email correctly.</p>
  
  <p>However, the <code>sendInvites</code> option only works when the event is newly created. If at a later time I call:</p>
  
  <pre><code>  var event = CalendarApp.getEventById("insert_id_here");
    event.addGuest("your.email+2@example.com");
  </code></pre>
  
  <p>... it does not send an email update (even though the event was created with <code>sendInvites=true</code>). This means <code>sendInvites</code> is transient and doesn't persist on the event.</p>
  
  <p>Is there any way to <code>sendInvites</code> when calling <code>addGuest()</code> on an event? E.g. <code>event.addGuest("user@example.com", {sendInvite: true})</code>?</p>
  
  <p>Are there any other workarounds that will produce the same email that is sent when hitting that "Send" button in the UI above?</p>
  
  <p>Note: I do <em>not</em> want to use MailApp to send an email because it won't be nicely formatted like the one Google automatically sends out (e.g. with embedded calendar invite, attendees, description, response links, etc, etc, etc).</p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <ul>
  <li>I just saw <a href="https://developers.google.com/apps-script/reference/calendar/calendar-event#getAllTagKeys()" rel="nofollow noreferrer">getAllTagKeys</a> in the API and was hoping I could use that to get the <code>sendInvites</code> key, but that's not the case. It is empty even for events that have <code>sendInvites</code> set to true.</li>
  </ul>