Microsoft Outlook provides a new task flagging system in which certain Outlook items such as mail items or contact items can be flagged for follow-up. 在 Outlook 使用者介面的 [To-Do 列] 和 [行事曆] 導覽模組上,標幟 Outlook 專案以進行後續追蹤時,會顯示該 Outlook 專案的相關資訊,以及其他以工作為基礎的資訊。
已擴充下列 Outlook 項目物件,以支援工作標幟系統:
將項目標示為工作
藉由檢查 Outlook 項目的 IsMarkedAsTask 屬性值,您可以判斷 Outlook 項目物件是否已標示為待處理事項。 使用 MarkAsTask 方法可以將 Outlook 項目標示為待處理事項,而使用 ClearTaskFlag 方法可以取消標示 Outlook 項目。
設定工作屬性
When an Outlook item is marked for follow-up using the MarkAsTask method, an OlMarkInterval constant is used to specify default settings for the TaskStartDate, TaskDueDate, TaskCompletedDate, and ToDoTaskOrdinal properties of the Outlook item. These properties are used not only to determine the duration and completion state of the task associated with the Outlook item, but also to determine the order in which the Outlook item is displayed in the To-Do Bar and Calendar navigation module.
不過,在呼叫 MarkAsTask 方法後,您可以透過程式設計方式個別地設定這些屬性,以支援自訂持續時間,或變更 Outlook 項目的完成狀態及顯示順序。
一旦 Outlook 項目標幟為待處理事項後,您也可以設定 Outlook 項目的 TaskSubject 屬性,以顯示除了已標幟 Outlook 項目之 Subject 屬性值以外的工作描述。
工作項目及工作標幟
TaskItem 物件支援 ToDoTaskOrdinal 屬性,所以也可以透過程式設計方式變更顯示在 [待辦事項列] 上之 Outlook 工作項目的顯示順序。
篩選標示為工作的項目
您可以利用 Outlook 的 DAV 搜尋及尋找 (DASL) 篩選功能,篩選標示為待處理事項的 Outlook 項目。 下列 Visual Basic for Applications (VBA) 範例會定義 DASL 篩選器,此功能只會篩選 IsMarkedAsTask 屬性值設定為 True 的 Outlook 項目,然後使用篩選建立 Table 物件,此物件含有從 [收件匣] 預設資料夾擷取之篩選過的 Outlook 項目。
Private Sub TableForIsMarkedAsTask()
Dim objTable As Outlook.Table
Dim objRow As Outlook.Row
Dim strFilter As String
On Error GoTo ErrRoutine
' Define a DASL filter string that filters only those items
' with an IsMarkedAsTask property value set to True.
strFilter = "@SQL=" & Chr(34) & _
"https://schemas.microsoft.com/mapi/proptag/0x0E2B0003" & _
Chr(34) & " = 1"
' Use the filter to construct a table of Outlook items
' retrieved from the Inbox default folder.
Set objTable = Application.Session.GetDefaultFolder(olFolderInbox).GetTable(strFilter)
With objTable
' Add task-related columns to the table.
.Columns.Add ("From")
.Columns.Add ("FlagRequest")
.Columns.Add ("TaskStartDate")
.Columns.Add ("TaskDueDate")
.Columns.Add ("TaskCompletedDate")
' Report the contents of the table
' to the Immediate window.
Do Until .EndOfTable
Set objRow = .GetNextRow
Debug.Print objRow("Subject"), _
objRow("From"), _
objRow("FlagRequest"), _
objRow("TaskStartDate"), _
objRow("TaskDueDate"), _
objRow("TaskCompletedDate")
Loop
End With
EndRoutine:
' Clean up
Set objRow = Nothing
Set objTable = Nothing
Exit Sub
ErrRoutine:
MsgBox Err.Number & " - " & Err.Description, _
vbOKOnly Or vbCritical, _
"TableForIsMarkedAsTask"
GoTo EndRoutine
End Sub
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。