Outlook加载项电子邮件项目标记

时间:2011-02-03 12:14:05

标签: c# .net outlook-addin

我需要一个建议。我们正在开发一个带有.net的Outlook插件,我需要调查,如果有办法为电子邮件创建一些自定义标记。我们需要对电子邮件执行操作,具体取决于之前是否在该电子邮件上执行,并在Outlook UI上显示此条件(如“read”,“unread”)。你能建议吗?

1 个答案:

答案 0 :(得分: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)