我正在编写一个显示日历的应用程序;当您单击日历上的日期时,它应显示一个窗口,列出当天的约会。
如何在VB.Net中完成?我可以找到将约会添加到日历的代码,但不能这样做。
答案 0 :(得分:0)
以下是使用Outlook Interop API的代码片段。
这段代码可以访问应用程序并获取所有日历项。如果您希望根据日期进行限制,可以调用clfFolder.Items.Restrict方法并传入限制过滤器。请注意,我在此方法中调用明确的重复项来形式化条目,而不是列出具有重复的单个项目。
Dim appOutlook As Outlook.Application = Me.OutlookFormRegion.Application
Dim mpnNamespace As Outlook.NameSpace = appOutlook.GetNamespace("MAPI")
Dim clfFolder As Outlook.Folder = _
mpnNamespace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar)
Dim itmItems As Outlook.Items
Dim oaiAppointmentItem As Outlook.AppointmentItem
clfFolder.Items.IncludeRecurrences = False
For Each oaiAppointmentItem In clfFolder.Items
oaiAppointmentItem.ClearRecurrencePattern()
Next
答案 1 :(得分:0)
我用它来查找数据。不确定是否有帮助
尝试
Dim olApp As Outlook.Application
olApp = CreateObject("Outlook.Application")
Dim mpnNamespace As Outlook.NameSpace = olApp.GetNamespace("MAPI")
Dim oCalendar As Outlook.MAPIFolder = mpnNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
Dim oItems As Outlook.Items = oCalendar.Items
oItems.Sort("Start")
oItems.IncludeRecurrences = True
Dim oAppt As Outlook.AppointmentItem = oItems.Find("[Subject] = 'Upgrade/Issue reported via eData - Ref:2'")
oAppt.Subject = "Updated"
oAppt.Save()
olApp = Nothing
Catch ex As Exception
MsgBox(ex.ToString)
End Try