创建一个与“发送等待响应”按钮关联的宏,以便使用自定义属性标记已发送的电子邮件:
Sub SendAwaitingResponse()
Dim Mail As MailItem
Set Mail = Outlook.Application.ActiveInspector.CurrentItem
Dim Property As UserProperty
Set Property = Mail.UserProperties.Add("FlagAwaitingResponse", olYesNo)
Property.Value = True
Mail.Send
End Sub
在 ThisOutlookSession 对象中,订阅添加到已发送邮件文件夹的项目。用自定义属性标记的项目将被标记为 Outlook 任务。
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim SentItems As Folder
Set SentItems = Outlook.Application.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail)
Set Items = SentItems.Items
End Sub
Private Sub Items_ItemAdd(ByVal Item As Object)
Dim Mail As MailItem
Set Mail = Item
Set Property = Mail.UserProperties("FlagAwaitingResponse")
If Property Is Nothing Then Exit Sub
Mail.Categories = "Awaiting Response"
Mail.MarkAsTask (olMarkToday)
Mail.Save
End Sub
不要忘记启用 Outlook 宏以使其正常工作。