2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Googleカレンダーの予定を作成する(GoogleAppsScript)

Last updated at Posted at 2021-01-27

#Calendar.createEvent

gcal.ts
function createEvent() {

  const title = 'タイトル';
  //予定時間の設定
  //実行日12:00から
  let startTime = new Date();
  startTime.setHours(12); 
  startTime.setMinutes(0);
  //実行日13:00まで
  let endTime = new Date();
  endTime.setHours(13); 
  endTime.setMinutes(0);
  //オプションを追加
  const options = {
  //   description:'説明', 
  //   location:'場所',       
  //   guests:'guests@gmail.com', //ゲスト
  //   sendInvites:true           //招待メールの送信
  }

  //デフォルトカレンダーに予定を作成
  const calendar = CalendarApp.getDefaultCalendar();
  // //IDでカレンダーを指定する場合
  // var calendar = CalendarApp.getCalendarById('{{id}}@group.calendar.google.com');
  const event = calendar.createEvent(title, startTime, endTime, options);
  Logger.log('createEvent: ' + event.getTitle());  //createEvent: title

}

繰り返し予定の作成では,明日以降にも予定が表示されてしまうので,
時間主導型トリガーを毎日0時に設定し,当日のみ表示しています。

#Reference
https://developers.google.com/apps-script/reference/calendar/calendar

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?