【问题标题】:VSTO outlook data issue through exchange sync通过交易所同步发布 VSTO Outlook 数据
【发布时间】:2018-06-19 23:02:46
【问题描述】:

我为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时发生的

产生问题的步骤:

  1. 点击按钮,获取LastModificationTime为“time1”

  2. 在我的手机中将开始日期更改为“start1”,通过Exchange服务器同步到Outlook

  3. 点击按钮,获取LastModificationTime,还是“time1”

  4. 在 Outlook 中将开始日期更改为“start2”,但约会仍处于“start1”日期。

  5. 重启outlook

  6. 点击按钮,获取新的LastModificationTime为“time2”,约会在“start1”日期,“start2”不见了。

没有问题的步骤

  1. 点击按钮,获取LastModificationTime为“time1”

1.1。重启展望

  1. 在我的手机中将开始日期更改为“start1”,通过Exchange服务器同步到Outlook

  2. 点击按钮,获取LastModificationTime, "time2"

看起来像 列出应用程序 如果约会通过交换服务器更改,则永远不会刷新到最新值。

这个问题有什么解决办法吗?或其他原因?

【问题讨论】:

    标签: c# outlook vsto outlook-addin


    【解决方案1】:

    没有看到你其他代码,但你需要记住释放约会对象 Marshal.ReleaseComObject。 您的客户端前景是否也处于缓存模式?

    马库斯

    【讨论】:

    • 嗨,谢谢,我测试了 Marshal.ReleaseComObject,它有效!!!但是当我访问约会的收件人时,另一个问题出现了,它不会释放对象,并且仍然只在循环内部添加旧的 LastModificationTime 值:if (Appt.Recipients.Count > 0) { }
    • 你能解释一下升技吗?你是说如果你遍历它的 Recipients 就不会释放约会?
    • 是的,如果我使用 Appt.Recipients.Count.Using apptrecipents = Appt.Recipients,然后 apptrecipents.Count,约会将不会被释放,现在一切都很好。谢谢。
    • 是的,这就是你必须声明它然后释放它的方式。
    【解决方案2】:

    我遇到了同样的问题,这是我的解决方案:

    用途:

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

    代替:

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

    区别在于 Outlook.MAPIFolder 和 Outlook.Folder,我不知道为什么,但 Outlook.Folder 对我有用。

    【讨论】:

      猜你喜欢
      • 2013-11-12
      • 1970-01-01
      • 1970-01-01
      • 2023-01-31
      • 1970-01-01
      • 2010-11-29
      • 2021-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多