Search code examples
pythonpython-3.xoutlookoffice-automation

Output Issue with FreeBusy for Outlook using Python


When I use the below code, the response is 11111001111100111110011111000 and 29. Which doesn't make sense because there are only 24 hours in a day. Is there something I am missing?

Also, is it possible to dynamically do this over a date range?

import win32com.client
from datetime import datetime

query_date = datetime(2022, 4, 18, 0, 0, 0, 0)

outlook = win32com.client.Dispatch('Outlook.Application')
namespace = outlook.GetNamespace("MAPI")
user = namespace.CreateRecipient("user@domain.com")
schedule = user.FreeBusy(query_date, 60 * 24)
print(schedule)
print(len(schedule))

Solution

  • You are asking for 60*24=1440 minutes per character, which means each character corresponds to the whole day. If you want one hour per character, pass 60.