如何为 Outlook 约会项目的类别着色

发布于 2024-10-15 23:26:20 字数 888 浏览 3 评论 0原文

我正在使用 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 中的约会根据类别集以不同的颜色显示。有什么方法可以手动设置类别颜色吗?或者甚至更好,一种让框架自动为我选择类别颜色的方法?

I'm using the office .NET framework to create appointments in Outlook. The code that creates the appointments looks like this:

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

This works just fine, but the category I'm setting does not have a colour associated with it. I want the appointments in outlook to appear in a different color depending on the category set. Is there some way i can manually set the category colours? Or even better, a way to get the framework to pick category colours for me automatically?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坦然微笑 2024-10-22 23:26:20

这个问题的答案涉及类别。具体来说,这里有一些代码(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 中设置,也可以在代码中创建类别时在上面的代码中设置。

The answer to this question deals with categories. Specifically, here's some code (VB.net, but easily convertable) that will create a dark olive category:

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

Category colors are either set in Outlook, or in the code above when creating a category in code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文