2011-02-03 111 views
3

私はオフィスの.NETフレームワークを使用してOutlookに予定を作成しています。Outlook AppointmentItemのカテゴリを色分けする方法

private void createCalendarEvent(DateTime start, DateTime end, String dept, String subj, String subjType, String room) 
    { 
     AppointmentItem apt = (AppointmentItem)OLapp.CreateItem(OlItemType.olAppointmentItem); 

     apt.Start = start; 
     apt.End = end; 
     apt.Subject = subj + " - " + subjType; 
     apt.Body = "Subject: " + subj + " (" + subjType + ")" 
       + "\nDepartment: " + dept 
       + "\nRoom: " + room 
       + "\n\nCreated by " + this.Text 
       + "\n On " + DateTime.Now.ToLongDateString() + " At " + DateTime.Now.ToLongTimeString(); 
     apt.Location = room; 
     apt.Categories = subj; 
     apt.Save(); 
    } 

これはうまく動作しますが、私は設定していたカテゴリがそれに関連付けられた色を持っていない:予定を作成するコードは次のようになります。カテゴリの設定によって、展望の予定が異なる色で表示されます。カテゴリ色を手動で設定できる方法はありますか?それとも、フレームワークで自動的にカテゴリの色を選択する方法ですか?

答えて

1

this questionへの回答はカテゴリを扱います。具体的には、ここでダークオリーブカテゴリを作成しますいくつかのコード(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 

カテゴリーの色はどちらか、Outlookの、またはコードでカテゴリを作成する際に上記のコードで設定されています。

関連する問題