LoginSignup
2
3

More than 1 year has passed since last update.

【Python】めんどうな会議予約を2分で終わらせてみた

Posted at

作ろうと思ったきっかけ

毎日の会議予約・報告が手間だったためツールを作りました。

このツールで出来ること

Outlookでの会議予約。
上司への報告用に文章を作成。

言語バージョン

C:\Users\test>python --version
Python 3.8.10

実装

dt = datetime.datetime.today()
num = 1
list = []
val_teams = "〇〇さん\n\
以下時間帯で会議を登録いたしました。\n"

# ---------報告用の文章を作成---------
def make_message(val2,val3,val4,val5):
    global num, val_teams
    val6 = val4 + ":" + val5
    after30m = datetime.datetime.strptime(val6, "%H:%M")
    after30m = after30m + datetime.timedelta(minutes=30)
    val7 = after30m.minute
    val7 = str(val7)
    if val7 == "0":
        val7 += "0"
    if val5 == "0":
        val5 += "0"

    a = "\n" + str(num) + ". \n\
    【日時】" + val2 + "/" + val3  + " " + val4 + ":" + val5 + "-" + str(after30m.hour) + ":" + val7 +\
    "\n【場所】\n\
    【ミーティングID】:000 000 000\n\
    【パスワード】:000000\n\
    【参加者URL】:https://xxxx?pwd=xxxx\n"

    int(num)
    num += 1
    val_teams += a
    # copy clipboard
    cl.copy(val_teams)

# ---------Outlookの会議予約用---------
def reserve_mail(val):
    outlook = win32com.client.Dispatch("Outlook.Application")
    sche = outlook.CreateItem(1)

    #yyyy-MM-dd hh:mm
    sche.Start = val
    sche.Subject = "〇〇会議"
    sche.Body = "〇〇会議のため、予定を入れさせていただきました。\n\
                場所は以下zoomにてお願い致します。\n\
                \n\
                ID: 000 000 000\n\
                パスワード:000000\n\
                URL:https://xxxx?pwd=xxxx"
    sche.Duration = "30" #m
    sche.Location = sche.Location = "https://xxxx?pwd=xxxx"
    sche.MeetingStatus = 1

    a = ["xxxxxxxx@xxxx.ne.jp"]

    for i in a:
        sche.Recipients.Add(i)
    sche.Send()

def add_list():
    val1 = combobox1.get()
    val2 = combobox2.get()
    val3 = combobox3.get()
    val4 = combobox4.get()
    val5 = combobox5.get()
    make_message(val2,val3,val4,val5)
    if val5 == "0":
        val5 += "0"
    val = val1 + "年" + val2 + "月" + val3 + "日" + " " + val4 + ":" + val5 + ""
    list.append(val)
    i = mb.askokcancel("予約リストへ追加しました", val)

def clear_list():
    list.clear()
    i = mb.askokcancel("", "予約リストを取り消しました")

def reserve():
    global val_teams
    b = "以下の時間帯で予約してもよろしいでしょうか\n"
    i = 1
    for a in list:
        b += str(i) + ". " + a + "\n"
        i += 1
    i = mb.askokcancel("予約リスト", b)
    if i:
        for val in list:
            reserve_mail(val)
        i = mb.askokcancel("", "Outlookへ登録完了です。以下文言をクリップボードに張り付けました。\n\n" + val_teams)
    else:
        print("予約がキャンセルされました")

# ---------tkinter用---------
# set Frame
root = tk.Tk()
root.title("会議予約")
root.geometry("435x120")

# year
combobox1 = ttk.Combobox(root, values=("2022", "2023"))
combobox1.set(dt.year)
combobox1.place(x=20, y=45, width=50, height=20)
label = tk.Label(text = "年")
label.place(x=74, y=45, width=20, height=20)

# month
combobox2 = ttk.Combobox(root, values=("1", "2", "3", "4", "5",
 "6", "7", "8", "9", "10", "11", "12"))
combobox2.set(dt.month)
combobox2.place(x=100, y=45, width=50, height=20)
label = tk.Label(text = "月")
label.place(x=150, y=45, width=30, height=20)

# day
combobox3 = ttk.Combobox(root, values=("1", "2", "3", "4", "5", "6",
"7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18",
"19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"))
combobox3.set(dt.day)
combobox3.place(x=180, y=45, width=50, height=20)
label = tk.Label(text = "日")
label.place(x=230, y=45, width=30, height=20)

# time
combobox4 = ttk.Combobox(root, values=("0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18",
"19", "20", "21", "22", "23"))
combobox4.set(dt.hour)
combobox4.place(x=260, y=45, width=50, height=20)
label = tk.Label(text = "時")
label.place(x=310, y=45, width=30, height=20)

# minute
combobox5 = ttk.Combobox(root, values=("0", "5", "10", "15", "20", "25",
"30", "35", "40", "45", "50", "55"))
combobox5.set(dt.minute)
combobox5.place(x=340, y=45, width=50, height=20)
label = tk.Label(text = "分")
label.place(x=390, y=45, width=30, height=20)

# make component
button1 = tk.Button(text="追加", command=add_list)
button2 = tk.Button(text="予約", command=reserve)
button3 = tk.Button(text="取消", command=clear_list)
button1.place(x=100, y=85)
button2.place(x=183, y=85)
button3.place(x=266, y=85)

root.mainloop()

詳細

会議予約用にポップアップを作成しています。

# make component
button1 = tk.Button(text="追加", command=add_list)
button2 = tk.Button(text="予約", command=reserve)
button3 = tk.Button(text="取消", command=clear_list)
button1.place(x=100, y=85)
button2.place(x=183, y=85)
button3.place(x=266, y=85)

root.mainloop()

画面イメージは以下の通り
キャプチャ.PNG

def reserve_mail(val):

リストに格納された予約時間をもとに、Outlookの会議予約を行っています。

def reserve_mail(val):
    outlook = win32com.client.Dispatch("Outlook.Application")
    sche = outlook.CreateItem(1)

    #yyyy-MM-dd hh:mm
    sche.Start = val
    sche.Subject = "〇〇会議"
    sche.Body = "〇〇会議のため、予定を入れさせていただきました。\n\
                場所は以下zoomにてお願い致します。\n\
                \n\
                ID: 000 000 000\n\
                パスワード:000000\n\
                URL:https://xxxx?pwd=xxxx"
    sche.Duration = "30" #m
    sche.Location = "https://xxxx?pwd=xxxx"
    sche.MeetingStatus = 1

    a = ["xxxxxxxx@xxxx.ne.jp"]

    for i in a:
        sche.Recipients.Add(i)
    sche.Send()

def make_message(val2,val3,val4,val5):

Outlookの予約内容をもとに、報告用の文章を作成しています。
クリップボードに保存しているため、最後は張り付けるだけで済みます。

def make_message(val2,val3,val4,val5):
    global num, val_teams
    val6 = val4 + ":" + val5
    after30m = datetime.datetime.strptime(val6, "%H:%M")
    after30m = after30m + datetime.timedelta(minutes=30)
    val7 = after30m.minute
    val7 = str(val7)
    if val7 == "0":
        val7 += "0"
    if val5 == "0":
        val5 += "0"

    a = "\n" + str(num) + ". \n\
    【日時】" + val2 + "/" + val3  + " " + val4 + ":" + val5 + "-" + str(after30m.hour) + ":" + val7 +\
    "\n【場所】\n\
    【ミーティングID】:000 000 000\n\
    【パスワード】:000000\n\
    【参加者URL】:https://xxxx?pwd=xxxx\n"

    int(num)
    num += 1
    val_teams += a
    # copy clipboard
    cl.copy(val_teams)

画面イメージは以下の通り
キャプチャ2.PNG

感想

タイトル通り、2分で会議予約ができるため重宝しています。
会議メンバー、会議の枠を調整できるよう変更を加える予定です。

最後までご覧いただきありがとうございました。

2
3
3

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
3