简体   繁体   English

通过交换同步处理VSTO Outlook数据问题

[英]VSTO outlook data issue through exchange sync

I wrote an addin for outlook, It will popup appointment's LastModificationTime while I click button 我为Outlook编写了一个插件,单击按钮时它将弹出约会的LastModificationTime。

the button eventhandler like this 像这样的按钮事件处理程序

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

the issue is happened while I changed appointment in my mobile phone, then sync it to the outlook through exchange server 我在手机中更改约会后发生问题,然后通过交换服务器将其同步到Outlook

steps which makes issue: 导致问题的步骤:

  1. click button, get LastModificationTime as "time1" 单击按钮,将LastModificationTime获取为“ time1”

  2. change start date as "start1" in my mobile phone, sync to outlook through exchange server 在我的手机中将开始日期更改为“ start1”,并通过交换服务器同步到Outlook

  3. click button, get LastModificationTime, still "time1" 单击按钮,获取LastModificationTime,仍为“ time1”

  4. change start date as "start2" in outlook, but the appointment is still in "start1" date. 在Outlook中将开始日期更改为“ start2”,但约会仍在“ start1”日期中。

  5. restart outlook 重新启动Outlook

  6. click button, get new LastModificationTime as "time2", and appointment is in "start1" date, "start2" is gone. 单击按钮,获取新的LastModificationTime作为“ time2”,并且约会在“ start1”日期中,“ start2”消失了。

steps without issue 没有问题的步骤

  1. click button, get LastModificationTime as "time1" 单击按钮,将LastModificationTime获取为“ time1”

1.1. 1.1。 restart outlook 重新启动Outlook

  1. change start date as "start1" in my mobile phone, sync to outlook through exchange server 在我的手机中将开始日期更改为“ start1”,并通过交换服务器同步到Outlook

  2. click button, get LastModificationTime, "time2" 单击按钮,获取LastModificationTime,“ time2”

It looks like List Appts is never been refreshed to latest value if the appointment is changed through exchange server. 如果约会通过Exchange服务器更改,则看来List Appts从未被刷新为最新值。

Is there any solution for this issue? 这个问题有解决方案吗? or other reason to make it happened? 或其他原因使之成为现实?

Not seeing you other code, but you need to remember to release the appointment objects Marshal.ReleaseComObject. 没有看到其他代码,但是您需要记住释放约会对象Marshal.ReleaseComObject。 Also is your client outlook in cache mode? 您的客户前景也处于缓存模式吗?

Marcus 马库斯

I've had same issue, and this is my solution: 我遇到了同样的问题,这是我的解决方案:

Use: 采用:

Outlook.Folder calFolder = outlookApplication.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.Folder;

Instead of: 代替:

Outlook.MAPIFolder folder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

The difference is Outlook.MAPIFolder and Outlook.Folder, I don't known why but Outlook.Folder works for me. 区别在于Outlook.MAPIFolder和Outlook.Folder,我不知道为什么,但是Outlook.Folder对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM