Home > Software engineering >  Output Issue with FreeBusy for Outlook using Python
Output Issue with FreeBusy for Outlook using Python

Time:04-20

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("[email protected]")
schedule = user.FreeBusy(query_date, 60 * 24)
print(schedule)
print(len(schedule))

CodePudding user response:

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

CodePudding user response:

The following code returns a string of free/busy information with one character for each day:

schedule = user.FreeBusy(query_date, 60 * 24)

And the following code returns a string of free/busy information with one character for each hour (complete format):

schedule = user.FreeBusy(query_date, 60, true)

See Recipient.FreeBusy for more information.

  • Related