0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

CopilotでOutlookから会議時間を集計するアプリを作成

Posted at

はじめに

Outlookの会議情報を効率的に管理したいと思ったことはありませんか?
私は、Outlookの会議情報を取得・集計し、Excelに出力するツール 「Outlook Meeting Project」 を開発しました。
このプロジェクトは Microsoft Copilot を活用して設計・実装を進めたものです。


Outlook Meeting Projectの主な機能

  • Outlookの会議情報を取得
  • 月ごとに件数と合計時間を集計
  • Excelファイルに保存
  • GUIで日付入力と保存先選択を可能に
  • PyInstallerで配布可能な .exe に変換
  • カテゴリーでの絞り込み機能
    👉 GitHubリポジトリはこちら

1. 毎月の工数入力が面倒

 毎月の工数入力がふと面倒だなと思ったとき、CopilotにOutlookから抽出できないか相談しました。すると、一発で下記のpythonコードを出力してくれました。実行環境がある人であれば十分な状態です。

import win32com.client
import datetime
from collections import defaultdict

# Outlookアプリケーションを初期化
outlook = win32com.client.Dispatch("Outlook.Application")
namespace = outlook.GetNamespace("MAPI")

# カレンダーフォルダを取得
calendar_folder = namespace.GetDefaultFolder(9)  # 9はカレンダーフォルダを指します

# カレンダーアイテムを取得
calendar_items = calendar_folder.Items

 
# カレンダーアイテムを開始日時でソートし、繰り返しの会議を含むように設定
calendar_items.Sort("[Start]")
calendar_items.IncludeRecurrences = True

# 会議の期間を定義(例:今年の4月から9月まで)
start_date = datetime.datetime(datetime.datetime.now().year, 4, 1)
end_date = datetime.datetime(datetime.datetime.now().year, 9, 30)
restriction = "[Start] >= '" + start_date.strftime("%m/%d/%Y %H:%M %p") + "' AND [End] <= '" + end_date.strftime("%m/%d/%Y %H:%M %p") + "'"
restricted_items = calendar_items.Restrict(restriction)

# 各月ごとの会議の詳細を格納する辞書を初期化
meetings_by_month = {month: defaultdict(lambda: {"count": 0, "total_duration": datetime.timedelta()}) for month in range(4, 10)}

# 制限されたアイテムを反復処理して会議の詳細を抽出
for item in restricted_items:
    if item.MeetingStatus in [1, 3]:  # 1は会議、3は会議リクエストを指します
        meeting_month = item.Start.month
        meeting_subject = item.Subject
        meeting_duration = datetime.timedelta(minutes=item.Duration)
       
        if meeting_month in meetings_by_month:
            meetings_by_month[meeting_month][meeting_subject]["count"] += 1
            meetings_by_month[meeting_month][meeting_subject]["total_duration"] += meeting_duration

# 各月ごとの会議の一覧と合計時間、回数を表示
for month, meetings in meetings_by_month.items():
    print(f"Meetings in month {month}:")
    for subject, details in meetings.items():
        print(f"  Subject: {subject}, Count: {details['count']}, Total Duration: {details['total_duration']}")
    print("\n")

 このままでも十分なのですが、GUIと追加機能をこのままCopilotに作成してもらいました。

2. 実装技術の決定

 とはいえ、pythonのライブラリもどれを使えばいいかわからないのでCopilotにきき、下記の方法でGUIを作成することにしました。

  • Python + win32com.client + pandas を採用。
  • tkinterでGUIを作成
  • PyInstallerで .exe を作成

3. 実行環境の整備

 そして、実際に開発する環境の整備ですが、これもCopilotにききながら整備しました。Pythonのバージョン管理は相談した結果、venvを採用しました。

python -m venv venv
source venv/bin/activate  # Windowsなら venv\Scripts\activate
pip install -r requirements.txt

4.実装

 実際作っていてうまくいかない場合もありました。会話を長く続けるとなぜか、固まってしまうのでやり直したり、ファイル間の連携がうまくいかなかったりしました。また、いくら聞いても解決できないバグは、ぐぐった方が速かったりしました。

5.GitHubのリリースノート

 かれこれ頑張って完成したものを今度はGitHubに載せます。ここで必要なリリースノートもCopilotに作成してもらいました。多少は手で修正が必要ですが、リリースに書くべきことを粗方だしてくれるので楽です。

おわり

 すべてをCopilotに頼り切って作成したアプリですが、月末になるとやっぱり使うので作って良かったと思います。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?