gpt4 book ai didi

c# - 按类别筛选 Outlook 约会

转载 作者:太空狗 更新时间:2023-10-29 22:19:39 25 4
gpt4 key购买 nike

我编写了这段代码来查找指定时间范围内指定类别的所有约会的总持续时间:

private readonly MAPIFolder _timing;

private int CalculateTotalDuration(DateTime start, DateTime end, string category)
{
string filter = String.Format(
"([Start] >= '{0:g}') AND ([End] <= '{1:g}') AND ([Categories] = '{2}')",
start, end, category);
return _timing.Items.Restrict(filter).Cast<AppointmentItem>().
Sum(appt => appt.Duration);
}

此代码在与俄语版本的 Outlook 一起使用时会导致以下异常(尽管我没有用英语版本对其进行测试):

System.Runtime.InteropServices.COMException was unhandled
Message=Условие неверно.
Source=Microsoft Outlook
ErrorCode=-2147352567
StackTrace:
at Microsoft.Office.Interop.Outlook._Items.Restrict(String Filter)
...

当我将 [Categories] 替换为 [Категории] 时,即

string filter = String.Format(
"([Start] >= '{0:g}') AND ([End] <= '{1:g}') AND ([Категории] = '{2}')",
start, end, category);

它适用于俄语版 Outlook。但显然它不适用于其他语言。

如何以多语言方式按类别过滤 Outlook 约会?

最佳答案

尝试使用 SQL 查询(在查询前加上“@SQL=")并为类别使用 DASL 名称 - http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/Keywords/0x0000101Furn:schemas:mailheader:keywords

关于c# - 按类别筛选 Outlook 约会,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14133471/

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