gpt4 book ai didi

c# - 如何为 Outlook AppointmentItem 的类别着色

转载 作者:行者123 更新时间:2023-11-30 12:52:17 25 4
gpt4 key购买 nike

我正在使用 office .NET 框架在 Outlook 中创建约会。创建约会的代码如下所示:

    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();
}

这工作得很好,但我设置的类别没有与之关联的颜色。我希望 outlook 中的约会根据类别集以不同的颜色显示。有什么方法可以手动设置类别颜色吗?或者更好的是,让框架自动为我选择类别颜色的方法?

最佳答案

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 中设置,要么在代码中创建类别时在上面的代码中设置。

关于c# - 如何为 Outlook AppointmentItem 的类别着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4892890/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com