如何使用 pywin32 创建具有重复工作日的 Outlook 约会?
How to create an Outlook appointment with recurring week days with pywin32?
我正在尝试创建一个具有重复工作日的 Outlook 约会。例如,周二和周五的某个时间。我查看了 VBA code 来执行此操作,如果您查看有问题的行,他们使用我认为是运算符的内容?
.DayOfWeekMask = olMonday Or olWednesday Or olFriday
我不完全确定它是否是一个运算符,因为 O 是大写的,我找不到这方面的任何信息。 python 的等价物是什么?下面是我的代码。
import win32com.client as win32
def create_event(subject, start_time, duration, location, body, recurring=False):
ol_app = win32.Dispatch('Outlook.Application')
event_item = ol_app.CreateItem(1) # Appointment item
event_item.Subject = subject
event_item.Start = start_time
event_item.Duration = duration
event_item.Location = location
event_item.Body = body
if recurring == True:
recurring_pattern = event_item.GetRecurrencePattern()
recurring_pattern.RecurrenceType = 1 # Weekly
recurring_pattern.PatternStartDate = '1/20/2022'
recurring_pattern.PatternEndDate = '5/2/2022'
recurring_pattern.DayOfWeekMask = 4 # OlDaysOfWeek enumeration for Tuesday.
event_item.Save()
RecurrencePattern.DayOfWeekMask property returns or sets an OlDaysOfWeek 常量表示重复约会或任务发生的星期几的掩码。相当于以下行:
.DayOfWeekMask = olMonday Or olWednesday Or olFriday
将是以下按位或操作:
.DayOfWeekMask = olMonday | olWednesday | olFriday
有关详细信息,请参阅 Bitwise Operators in Python。
我正在尝试创建一个具有重复工作日的 Outlook 约会。例如,周二和周五的某个时间。我查看了 VBA code 来执行此操作,如果您查看有问题的行,他们使用我认为是运算符的内容?
.DayOfWeekMask = olMonday Or olWednesday Or olFriday
我不完全确定它是否是一个运算符,因为 O 是大写的,我找不到这方面的任何信息。 python 的等价物是什么?下面是我的代码。
import win32com.client as win32
def create_event(subject, start_time, duration, location, body, recurring=False):
ol_app = win32.Dispatch('Outlook.Application')
event_item = ol_app.CreateItem(1) # Appointment item
event_item.Subject = subject
event_item.Start = start_time
event_item.Duration = duration
event_item.Location = location
event_item.Body = body
if recurring == True:
recurring_pattern = event_item.GetRecurrencePattern()
recurring_pattern.RecurrenceType = 1 # Weekly
recurring_pattern.PatternStartDate = '1/20/2022'
recurring_pattern.PatternEndDate = '5/2/2022'
recurring_pattern.DayOfWeekMask = 4 # OlDaysOfWeek enumeration for Tuesday.
event_item.Save()
RecurrencePattern.DayOfWeekMask property returns or sets an OlDaysOfWeek 常量表示重复约会或任务发生的星期几的掩码。相当于以下行:
.DayOfWeekMask = olMonday Or olWednesday Or olFriday
将是以下按位或操作:
.DayOfWeekMask = olMonday | olWednesday | olFriday
有关详细信息,请参阅 Bitwise Operators in Python。