leo*_*ora 6 c# outlook vsto calendar
我有一个Outlook VSTO插件,我可以使用以下代码检索日历约会列表:
private Items GetAppointmentsInRange(Folder folder, DateTime startTime, DateTime endTime)
{
string filter = "[Start] >= '"
+ startTime.ToString("g")
+ "' AND [End] <= '"
+ endTime.ToString("g") + "'";
Debug.WriteLine(filter);
try
{
Items calItems = folder.Items;
calItems.IncludeRecurrences = true;
calItems.Sort("[Start]", Type.Missing);
Items restrictItems = calItems.Restrict(filter);
if (restrictItems.Count > 0)
{
return restrictItems;
}
else
{
return null;
}
}
catch
{
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
我可以遍历这个预约项并获取entryId,我被告知是该系列的唯一标识符.
我现在试图弄清楚,给定一个EntryId,什么是正确的代码来直接引用约会项目系列(无需搜索所有内容并过滤"客户端")
这在outlook vsto中是否可行?
如果您想通过 获取项目 ( MailItem, FolderItem, AppoinmentItem, ...) EntryID,则需要使用GetItemFromID(),此方法返回由指定条目 ID 标识的Microsoft Outlook 项目(如果有效)。
该函数在对象中可用NameSpace,您可以使用Application.Session属性或app.GetNamespace("MAPI")调用来获取它:
var app = new Microsoft.Office.Interop.Outlook.Application();
...
var ns = app.Session; // or app.GetNamespace("MAPI");
var entryID = "<apppoinment entry id>";
var appoinment = ns.GetItemFromID(entryID) as AppointmentItem;
Run Code Online (Sandbox Code Playgroud)
但建议提供文件夹的 ID:
var entryID = "<apppoinment entry id>";
var storeID = "<folder store id>";
var appoinment = ns.GetItemFromID(entryID, store) as AppointmentItem;
Run Code Online (Sandbox Code Playgroud)
请注意,EntryID如果您将商品移至另一家商店,情况可能会发生变化。
此外,Microsoft 建议解决方案不应依赖于EntryID属性的唯一性,除非项目不会被移动,例如,如果您调用Respond()方法olMeetingAccepted或创建olMeetingTentative具有不同的新约会项目EntryID并删除原始项目。
| 归档时间: |
|
| 查看次数: |
1043 次 |
| 最近记录: |