I am trying to automate calendar invites with a little script but I keep hitting an error that I just don't understand. I have all the different elements used in the appt in a pandas dataframe and I have been trying to change between datetime and string to check if that's the problem but it doesn't seem to be the issue. After some data management I try this:
for index, row in df.iterrows():
appt = outlook.CreateItem(1)
appt.Start = df['from_date'] # yyyy-MM-dd hh:mm
appt.Subject = df['description']
appt.Duration = df['timediff']
appt.Location = df['room']
appt.MeetingStatus = 1
appt.Recipients.Add("email@email.com")
appt.Organizer = 'email@email.com'
appt.Save()
appt.Send()
appt.Close()
Now, the elements in the "from_date" looks like this 2019-10-28 08:15
But I get this error (with a little translation on my part, since outlook is in local language):
File "C:/Users/.../autobooking.py", line 65, in <module>
appt.Start = df['from_date'] # yyyy-MM-dd hh:mm
File "C:\Users\...\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 565, in __setattr__
self._oleobj_.Invoke(entry.dispid, 0, invoke_type, 0, value)
com_error: (-2147352567, 'Exception occured.', (4096, 'Microsoft Outlook', 'The object does not support this method.', None, 0, -2147352567), None)
Edit: I have a feeling that it is because of the pandas property. If I print the elements of the rows, I get the index number printed as well. Perhaps the index number is included in the appt.Start? Can I make sure that using df['from_date'] does not include the index number?