0

メソッドの高度なオプション パラメータを使用して、ゲスト リストに特定の電子メール アドレスを持つカレンダーからすべてのイベントを取得するにはどうすればよいgetEvents()ですか?

前もって感謝します

4

1 に答える 1

2

optionsパラメーターはgetEvents()、イベントのゲスト リストを検索する方法を提供しません。

ゲスト リストに指定された電子メール アドレスを持つイベントのみを含むイベント リストを返す関数を次に示します。この関数はgist としても利用できます

/**
 * Gets all events that occur within a given time range,
 * and that include the specified guest email in the
 * guest list.
 *
 * @param {Calendar} calen Calendar to search
 * @param {Date} start the start of the time range
 * @param {Date} end the end of the time range, non-inclusive
 * @param {String} guestEmail Guest email address to search for
 *
 * @return {CalendarEvent[]} the matching events
 */
function getEventsWithGuest(calen,start,end,guestEmail) {
  var events = calen.getEvents(start, end);
  var i = events.length;
  while (i--) {
    if (!events[i].getGuestByEmail(guestEmail)) {
      events.splice(i, 1);
    }
  }
  return events;
}

// Test function
function test_getEventsWithGuest() {
  var calen = CalendarApp.getDefaultCalendar();
  var now = new Date();
  // then... four weeks from now
  var then = new Date(now.getTime() + (4 * 7 * 24 * 60 * 60 * 1000));

  var events = getEventsWithGuest(calen,now,then,'guest@somewhere.com');

  Logger.log('Number of events: ' + events.length);
}
于 2013-05-09T11:27:14.523 に答える