VBA:阅读展望日历 - 不读经常性约会?

时间:2015-05-12 14:49:39

标签: vba calendar outlook

我正在阅读展望日历。使用我在本网站上研究过的方法:

Dim oOL As New Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oAppointments As Object
Dim oAppointmentItem As Outlook.AppointmentItem

Set oNS = oOL.GetNamespace("MAPI")
Set oAppointments = oNS.GetDefaultFolder(olFolderCalendar)

For Each oAppointmentItem In oAppointments.Items

    DoEvents
    ' Something here
Next

Set oAppointmentItem = Nothing
Set oAppointments = Nothing
Set oNS = Nothing
Set oOL = Nothing

我注意到它没有引入我在日历中接受的前瞻定期约会。这是预期的行为吗?如果没有,我会撕掉代码并尝试别的东西。

1 个答案:

答案 0 :(得分:0)

要从文件夹中检索所有Outlook约会项目,您需要按升序对项目进行排序,并将IncludeRecurrences设置为true。如果你以前没有这样做,你就不会抓到经常性的约会!

 For Each oAppointmentItem In oAppointments.Items
    DoEvents
   ' Something here
 Next

该文件夹可能包含许多日历项目。因此,我建议使用Items类的Find / FindNext或Restrict方法来获取指定日期的项目。您可以在MSDN的以下系列文章中阅读有关这些方法的更多信息:

相关问题