Sub AutoCancel(ByRef Item As Outlook.MeetingItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim oMeetingItem As Outlook.MeetingItem
Dim oResponse As Outlook.MeetingItem
Dim oAppointment As Outlook.AppointmentItem
strID = Item.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set oMeetingItem = olNS.GetItemFromID(strID)
Set oAppointment = oMeetingItem.GetAssociatedAppointment(False)
oAppointment.Delete
Set oAppointment = Nothing
Set oMeetingItem = Nothing
Set olNS = Nothing
End Sub
我有大量订阅/取消的电子邮件,我希望自动接受或取消,然后从收件箱中删除。 accept方法似乎有效,但是此方法会针对指向oAppointment.Delete
行的每次取消向用户发送调试报告。
我的想法是,在oMeetingItem.GetAssociatedAppointment返回null的某些情况下,它出错了,因此它没有任何内容可以删除。这只是一种预感。有什么想法吗?
答案 0 :(得分:0)
是的,如果您将false传递给GetAssociatedAppointment,它将不创建约会(如果它尚不存在)。