Access Room Calendar Information via Python MAPI

Jared Cohen 0 Reputation points
2025-03-19T10:59:14.5066667+00:00

Hello!

I hope you are doing well today.

I am looking to write a python script that access a room's event organizers and free/busy times without using Graph or Exchange APIs.

At the moment, I am able to get the Free/Busy Time through a Free/Busy function available through win32com's MAPI.

import pywintypes
import win32com.client
MINUTE_INTERVAL = 15
outlook = win32com.client.Dispatch("Outlook.Application")
namespace = outlook.GetNamespace("MAPI")
recipient = namespace.CreateRecipient(room_email)
my_date = pywintypes.Time(datetime.combine(date, time(0, 0, 0)))
free_busy_str = str(recipient.FreeBusy(my_date, MINUTE_INTERVAL))

I was curious if a function exists where I can get additional meeting info, as it shows when I am in outlook's Calendar app.

Currently I have a solution that shows my current calendar

folder = namespace.GetDefaultFolder(9) # 9 = olFolderCalendar
calendar = folder.Items

but this does not get the information from a shared room calendar effectively -- calendar events that are in the conference room BUT are not a part of my calendar are not shown.

I tried this:

folder = namespace.GetSharedDefaultFolder(recipient, 9)

but I did not appear to have access to this calendar's information, despite me being able to see the organizer and free/busy times on the outlook app.

Thank you!

Outlook | Windows | Classic Outlook for Windows | For business
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. simo-k 67,805 Reputation points Volunteer Moderator
    2025-03-19T18:53:16.86+00:00

    Please refer to the following, which is based on VBA.
    Find the conference room in the store object and refer to the calendar folder.

    Sub Get_ResourceConferenceRoom()
        Dim iii As Long
        Dim zzz As Long
        Dim ResFolder   As Outlook.folder
        Dim ResCalendar As Outlook.folder
        Set ResFolder = Application.Session.Stores.Session.Folders("Room-ABC")  ' Conference Room name
        Set ResCalendar = ResFolder.Folders("予定表")                           ' Calendar ??
        zzz = ResCalendar.Items.Count
        For iii = 1 To zzz
            With ResCalendar.Items(iii)
                Debug.Print .Start & ":" & .Subject
            End With
        Next
        Set ResCalendar = Nothing
        Set ResFolder = Nothing
    End Sub
    

    <Japanese>
    VBAベースとなりますが下記を参考にしてみて下さい。
    ストアーオブシェクトの中から会議室を探し出して、予定表のフォルダを参照して下さい。


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.