2011-02-03 81 views
0

我需要一個建議。我們正在用.net開發一個Outlook加載項,並且我需要調查一下,如果有辦法爲電子郵件創建一些自定義標記。我們需要對電子郵件執行操作,具體取決於它是否在此電子郵件上執行過,並在Outlook用戶界面上顯示此條件(如「讀取」,「未讀」)。你能建議一些事嗎?Outlook加載項郵件標記

回答

2

您可以使用Outlook 2007或更高版本中的類別執行此操作。類別是一種顏色編碼標籤系統,可以很好地工作,因爲您可以在電子郵件中放置一個或多個類別,並且插件可以根據需要創建新的類別。可悲的是,我沒有用C#編寫有用的示例代碼,但我在VB.net中確實有一些應用程序仍然有幫助。 :)

對於您的具體問題,您需要處理電子郵件,然後使用類別標記您已經處理了這些電子郵件。由於類別標籤也顯示在用戶界面中,用戶將能夠輕鬆看到它。

Private Shared ReadOnly CATEGORY_TEST As String = "Custom Overdue Activity" 

' This method checks if our custom category exists, and creates it if it doesn't. 
Private Sub SetupCategories() 
    Dim categoryList As Categories = Application.Session.Categories 
    For i As Integer = 1 To categoryList.Count 
     Dim c As Category = categoryList(i) 
     If c.Name.Equals(CATEGORY_TEST) Then 
      Return 
     End If 
    Next 

    categoryList.Add(CATEGORY_TEST, Outlook.OlCategoryColor.olCategoryColorDarkOlive) 
End Sub 


' This snippet creates a new Task in Outlook, and assigns the category. 
' The process for categories is similar when putting them on an email instead. 
' Some of the data here is coming from a web service call in a larger app, you can ignore that. :) 
Dim task As Outlook.TaskItem = DirectCast(Application.CreateItem(Outlook.OlItemType.olTaskItem), Outlook.TaskItem) 
       task.DueDate = Date.Parse(activity.ActDate) 
       task.StartDate = task.DueDate 
       task.Subject = String.Format(subjectText, activity.AppID) 
       task.Body = String.Format(bodyText, activity.AppID, activity.FileNum, activity.AppID) 
       task.ReminderTime = Now.AddMinutes(10) 
       task.ReminderSet = True 
       task.Categories = CATEGORY_TEST 
       task.Save() 
       task.Close(OlInspectorClose.olDiscard) 
相關問題