Включить повторяющиеся встречи - PullRequest
0 голосов
/ 24 июня 2019

Я пытаюсь получить все встречи от клиента Outlook с Python и Win32com. клиент, я просто хочу получать все встречи с 2019 года, чтобы я мог ограничить пункты назначения, но когда я ограничиваю их, я не получаю повторяющиеся встречи.

Я уже пытался включить повторяющиеся элементы с назначениями. IncludeRecurferences = "True", но это не помогло.

import win32com.client
import time
import datetime
import os


f=open("mem.txt", "w")
counter=0
outlook= win32com.client.Dispatch("Outlook.Application")
namespace=outlook.GetNamespace("MAPI")
recipient = namespace.createRecipient("Some Calender")
resolved = recipient.Resolve()
sharedCalendar = namespace.GetSharedDefaultFolder(recipient, 9)
appointments = sharedCalendar.Items

# Restrict items
begin = datetime.date(2019, 1, 1)
end = datetime.date(2019, 12, 30)
restriction = "[Start] >= '" + begin.strftime("%m/%d/%Y") + "' AND [End] <= '" +end.strftime("%m/%d/%Y") + "'"
restrictedItems = appointments.Restrict(restriction)
appointments.IncludeRecurrences = "True"

# Iterate through restricted AppointmentItems
for appointmentItem in restrictedItems:
    month= appointmentItem.Start
    month=str(month)[5:-18] #just trim the month out of the date
    if month=='08': #need appointments from specific
        #mystuff
        #the code works but I want the recurring appointments too
print(counter)
f.close()

Ответы [ 2 ]

0 голосов
/ 24 июня 2019

Во-первых, чтобы извлечь все элементы встречи Outlook из папки, которая соответствует предопределенному условию, необходимо отсортировать элементы в порядке возрастания и установить для IncludeRecurrences значение true. Вы не будете ловить повторяющиеся встречи, если не сделаете этого до использования метода Restrict!

    folderItems = folder.Items;
    folderItems.IncludeRecurrences = true;
    folderItems.Sort("[Start]");
    resultItems = folderItems.Restrict(restrictCriteria);

Вам могут пригодиться следующие статьи:

0 голосов
/ 24 июня 2019

Вы пытались установить IncludeRecurrences в True перед ограничением ваших предметов?

По сути, переключая эти две строки:

restrictedItems = appointments.Restrict(restriction)
appointments.IncludeRecurrences = "True"
...