运行Office365。我试图将任务分配给用户,并使其自动接受(由于某种原因这不是Outlook中的默认功能)。我已经研究并提出了以下代码:
Public WithEvents objInbox As Outlook.Folder
Public WithEvents objItems As Outlook.Items
Private Sub Application_Startup()
Set objInbox = Outlook.Application.Session.GetDefaultFolder(olFolderInbox)
Set objItems = objInbox.Items
End Sub
Private Sub objItems_ItemAdd(ByVal Item As Object)
Dim objTaskRequest As Outlook.TaskRequestItem
Dim objTask As Outlook.TaskItem
Dim objResponse As Object
If TypeOf Item Is TaskRequestItem Then
Set objTaskRequest = Item
Set objTask = objTaskRequest.GetAssociatedTask(True)
Set objResponse = objTask.Respond(olTaskAccept, True, True)
objResponse.Send
objResponse.Delete
objTaskRequest.Delete
End Sub
有什么想法吗?