C# 通过exchange同步发送VSTO outlook数据
我为outlook编写了一个加载项,当我单击按钮时,它将弹出约会的LastModificationTime 按钮事件处理程序如下所示C# 通过exchange同步发送VSTO outlook数据,c#,outlook,vsto,outlook-addin,C#,Outlook,Vsto,Outlook Addin,我为outlook编写了一个加载项,当我单击按钮时,它将弹出约会的LastModificationTime 按钮事件处理程序如下所示 Outlook.ApplicationClass outlook = new Outlook.ApplicationClass(); Outlook.NameSpace ns = outlook.GetNamespace("MAPI"); Outlook.MAPIFolder folder = ns.GetDefaultFolder(Outlook.O
Outlook.ApplicationClass outlook = new Outlook.ApplicationClass();
Outlook.NameSpace ns = outlook.GetNamespace("MAPI");
Outlook.MAPIFolder folder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
Outlook.Items FolderItems = folder.Items;
DateTime MyDate = DateTime.Now;
List<Outlook.AppointmentItem> Appts = (
from Outlook.AppointmentItem i in folder.Items
where i.Start.Month == MyDate.Month && i.Start.Year == MyDate.Year
select i).ToList();
foreach (Outlook.AppointmentItem Appt in Appts)
{
System.Windows.Forms.MessageBox.Show(Appt.LastModificationTime.ToString());
}
Outlook.ApplicationClass Outlook=新建Outlook.ApplicationClass();
Outlook.NameSpace ns=Outlook.GetNamespace(“MAPI”);
Outlook.MAPIFolder folder=ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
Outlook.Items FolderItems=文件夹.Items;
DateTime MyDate=DateTime.Now;
列表应用=(
从文件夹.Items中的Outlook.AppointmentItem i
其中i.Start.Month==MyDate.Month&&i.Start.Year==MyDate.Year
选择i.ToList();
foreach(应用中的Outlook.AppointmentItem应用)
{
System.Windows.Forms.MessageBox.Show(Appt.LastModificationTime.ToString());
}
问题发生在我在移动电话中更改约会,然后通过exchange server将其同步到outlook时
提出问题的步骤:
这个问题有什么解决办法吗?或者是其他原因造成的?没有看到其他代码,但您需要记住释放约会对象 Marshal.ReleaseComObject。 您的客户端outlook是否也处于缓存模式
马库斯我也遇到过同样的问题,这是我的解决方案: 使用: 而不是:
Outlook.MAPIFolder folder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
区别在于Outlook.MAPIFolder和Outlook.Folder,我不知道为什么,但是Outlook.Folder适合我。您好,谢谢,我测试了Marshal.ReleaseComObject,它可以工作!!!但另一个问题是,当我访问约会的收件人时,它并没有释放对象,并且仍然只在循环内添加旧的LastModificationTime值:if(Appt.recipients.Count>0){}您能解释一下吗?你是说如果你浏览了约会的收件人,约会不会被释放吗?是的,如果我使用Appt.Recipients.Count.Using ApptRecipients=Appt.Recipients,然后是ApptRecipients.Count,约会不会被释放,现在一切都好了。谢谢。是的,这就是你必须声明它然后发布它的方式。
Outlook.MAPIFolder folder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);