共用方式為


標幟主管的郵件專案以進行後續追蹤

此範例示範如何標幟從用戶經理收到的電子郵件專案以進行後續追蹤。

範例

注意事項

下列程式代碼範例是 Microsoft Office Outlook 2007 程式設計應用程式的摘錄。

Microsoft Outlook 提供工作旗標系統,可在其中標示某些 Outlook 專案,例如郵件專案或聯繫人專案,以進行後續追蹤。 當您為 Outlook 專案加上旗標以進行後續追蹤時,該 Outlook 專案的相關信息以及其他以工作為基礎的資訊會顯示在 Outlook 使用者介面中的 [To-Do 列] 和 [行事歷] 瀏覽模組上。 To-Do 會在 Outlook 總管視窗的一般設定中顯示為垂直窗格。 其中包含日期導覽器控件、即將推出的約會,以及已標示為待處理的專案。 To-Do 列本身無法擴充,而且您只能透過 Outlook 使用者介面設定 To-Do 列的設定選項。 標幟專案可讓您組織和排定工作和待辦專案的優先順序。

下列程式代碼範例會標示指定之後續追蹤間隔的專案群組。 此範例會使用 DAV 搜尋和尋找 DAS) L (查詢來篩選類型為 “IPM” 的訊息,以取得目前使用者收件匣中所有來自目前使用者管理員的專案。附注」,並以經理的名稱做為寄件者。 然後,它會根據 Importance 屬性的OlImportance 值來標幟所有專案。 所有高重要性項目都會標幟為現今的待處理專案,並使用 MarkAsTask (OlMarkInterval) 方法標 幟為要在本周進行後續追蹤的所有一般重要性專案。

注意事項

Importance 屬性和 MarkAsTask 方法是 Item 物件成員。

If you use Visual Studio to test this code example, you must first add a reference to the Microsoft Outlook 15.0 Object Library component and specify the Outlook variable when you import the Microsoft.Office.Interop.Outlook namespace. The using statement must not occur directly before the functions in the code example but must be added before the public Class declaration. The following line of code shows how to do the import and assignment in C#.

using Outlook = Microsoft.Office.Interop.Outlook;
private void DemoTaskFlagging()
{
    const string PR_SENT_REPRESENTING_NAME =
        "http://schemas.microsoft.com/mapi/proptag/0x0042001E";
    const string PR_MESSAGE_CLASS =
        "http://schemas.microsoft.com/mapi/proptag/0x001A001E";
    Outlook.AddressEntry currentUser =
        Application.Session.CurrentUser.AddressEntry;
    if (currentUser.Type == "EX")
    {
        Outlook.ExchangeUser manager;
        try
        {
            manager = currentUser.
                GetExchangeUser().GetExchangeUserManager();
        }
        catch
        {
            Debug.WriteLine("Could not obtain user's manager.");
            return;
        }
        if (manager != null)
        {
            string displayName = manager.Name;
            string filter = "@SQL=" + "\""
                + PR_SENT_REPRESENTING_NAME + "\""
                + " = '" + displayName + "'" + " AND " + "\""
                + PR_MESSAGE_CLASS + "\"" + " = 'IPM.NOTE'";
            Outlook.Items items =
                Application.Session.GetDefaultFolder(
                Outlook.OlDefaultFolders.olFolderInbox).
                Items.Restrict(filter);
            foreach (Outlook.MailItem mail in items)
            {
                if (mail.Importance ==
                    Outlook.OlImportance.olImportanceHigh)
                {
                    mail.MarkAsTask(Outlook.OlMarkInterval.olMarkToday);
                    mail.Save();
                }
                if (mail.Importance ==
                    Outlook.OlImportance.olImportanceNormal)
                {
                    mail.MarkAsTask(Outlook.OlMarkInterval.olMarkThisWeek);
                    mail.Save();
                }
            }
        }
    }
}

另請參閱