0

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?

Rolf
  • 7
  • 4
  • The property is not correctly formatted, as per [AppointmentItem.Start property (Outlook)](https://learn.microsoft.com/en-us/office/vba/api/outlook.appointmentitem.start). `.Start = #9/24/2003 1:30:00 PM# ` is the correct format. – Trenton McKinney Dec 14 '19 at 21:02
  • Well, if I just manually type in the fields outside a loop, this format creates an appointment at the correct time 2019-10-28 08:15 – Rolf Dec 14 '19 at 21:38

0 Answers0