Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 通过exchange同步发送VSTO outlook数据_C#_Outlook_Vsto_Outlook Addin - Fatal编程技术网

C# 通过exchange同步发送VSTO outlook数据

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编写了一个加载项,当我单击按钮时,它将弹出约会的LastModificationTime

按钮事件处理程序如下所示

  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时

提出问题的步骤:

  • 单击按钮,将LastModificationTime设置为“time1”

  • 在我的手机中将开始日期更改为“start1”,通过exchange server同步到outlook

  • 单击按钮,获取LastModificationTime,仍然是“time1”

  • 在outlook中将开始日期更改为“开始2”,但约会仍在“开始1”日期

  • 重新启动outlook

  • 点击按钮,将新的LastModificationTime设置为“time2”,约会在“start1”日期,“start2”消失

  • 毫无疑问的步骤

  • 单击按钮,将LastModificationTime设置为“time1”
  • 1.1。重新启动outlook

  • 在我的手机中将开始日期更改为“start1”,通过exchange server同步到outlook

  • 单击按钮,获取LastModificationTime,“time2”

  • 看起来像 列表应用程序 如果通过exchange server更改约会,则从未刷新到最新值


    这个问题有什么解决办法吗?或者是其他原因造成的?

    没有看到其他代码,但您需要记住释放约会对象 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);