Outlook会根据类别自动更改提醒

时间:2009-03-20 17:16:59

标签: vba outlook outlook-vba

我需要自动化Outlook,以便当用户在约会上设置某个类别时,它会根据类别自动设置提醒时间。

例如,用户具有“现场会议”类别和“场外会议”类别。他希望提醒时间自动更改为现场会议的15分钟和非现场会议的30分钟。他理解如果他将类别设置错误或应用两个类别,时间就不会正确改变。

是否可以这样做,如果是这样,我该怎么做呢?我想有一个事件,我可以在约会类别改变时抓住并处理。

谢谢

编辑:通过电子邮件收到约会请求,他在接受会议请求时设置类别。每当类别更改时,都应设置提醒时间。 如何与事件挂钩是我无法找到的部分。

2 个答案:

答案 0 :(得分:0)

什么时候应该改变提醒时间?最初撰写会议时?什么时候修改类别?

(例如,如果用户已经为提醒设置了值,然后更改了类别,提醒会改变吗?)

无论如何,我想解决方案是连接到Outlook中发生的一些事件,并根据你的逻辑设置这些值。但是,在上述问题得到解答之前,您不清楚需要与哪些事件联系起来。

答案 1 :(得分:0)

您需要ItemAdd和ItemChange

http://msdn.microsoft.com/en-us/library/office/ff869609(v=office.14).aspx

http://msdn.microsoft.com/en-us/library/office/ff865866(v=office.14).aspx

这样的事情:

Public Sub Application_Startup()
    Set objCalendar = Outlook.Session.GetDefaultFolder(olFolderCalendar).Items
End Sub

Private Sub objCalendar_ItemAdd(ByVal Item As Object)
    setReminder Item
End Sub

Private Sub objCalendar_ItemChange(ByVal Item As Object)
    setReminder Item
End Sub

Sub setReminder(ByVal Item As Object)
    If InStr(Item.Categories, "A")
        ' Set the reminder time A
        GoTo exitRoutine ' A the longer takes priority over B the shorter
    End If

    If InStr(Item.Categories, "B")
        ' Set the reminder time B
    End If

exitRoutine:

End Sub