1
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.

WSH/JScriptでOutlookの予定表を取得する

Posted at

Excel VBAでOutlookの予定表を取得する記事は多数あったが、JScriptでの実装方法を記した記事はほとんど見つからなかったので備忘録としてまとめる。
公式リファレンスを見ながら手探りで作ったのでおかしな点があるかもしれない。(そもそも公式のサンプルもVBやC#ばかりでJScriptでのサンプルは見当たらない)
あと、JScript触れたのは今回が初。


var START = "2021/2/1";
var END = "2021/2/4";

// フォルダーの種類を指定
var olFolderCalendar = 9;   // 9が予定表を指す

// outlookオブジェクトと名前空間生成
var olObj = new ActiveXObject("Outlook.Application");
var olNameSpace = olObj.GetNamespace("MAPI")

// フィルタを設定して予定表を取得
var appointments = olNameSpace.GetDefaultFolder(olFolderCalendar).Items;
appointments.Sort("[Start]");           // 開始日でソート
appointments.IncludeRecurrences = true; // 定期的な予定も検索に含める。通常、定期的な予定は特定の日付と関連していないため取得されない。
appoObj = appointments.Find("[Start] >= '" + START + "' And [Start] <= '" + END + "'");

// 取得したAppointmentItemsから予定取得
while(appoObj){
    // ここでは題名、開始時刻、終了時刻、会議出席者を取得している
    WScript.StdOut.WriteLine(appoObj.Subject + "," + appoObj.Start + "," + appoObj.End + "," + appoObj.RequiredAttendees);
    // 次の予定へ
    appoObj = appointments.FindNext;
}

リファレンス

1
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
1
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?