VSTO通过exchange同步发布outlook数据
我为 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,这会导致问题:
点击按钮,获取LastModificationTime为“time1”
将手机中的开始日期更改为“start1”,通过exchange服务器同步到outlook
点击按钮,获取LastModificationTime,仍为“time1”
将开始日期更改为Outlook 中的“start2”,但约会仍处于“start1”日期。
重新启动 Outlook
单击按钮,获取新的 LastModificationTime 为“time2”,约会是在“start1”日期,“start2”已消失。
步骤没有问题
- 单击按钮,将 LastModificationTime 获取为“time1”
1.1。重新启动 Outlook
在手机中将开始日期更改为“start1”,通过 Exchange 服务器同步到 Outlook
单击按钮, get LastModificationTime, "time2"
看起来像 列出应用程序 如果通过交换服务器更改约会,则永远不会刷新为最新值。
这个问题有什么解决办法吗?或其他原因使其发生?
I wrote an addin for outlook, It will popup appointment's LastModificationTime while I click button
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
steps which makes issue:
click button, get LastModificationTime as "time1"
change start date as "start1" in my mobile phone, sync to outlook through exchange server
click button, get LastModificationTime, still "time1"
change start date as "start2" in outlook, but the appointment is still in "start1" date.
restart outlook
click button, get new LastModificationTime as "time2", and appointment is in "start1" date, "start2" is gone.
steps without issue
- click button, get LastModificationTime as "time1"
1.1. restart outlook
change start date as "start1" in my mobile phone, sync to outlook through exchange server
click button, get LastModificationTime, "time2"
It looks like
List Appts
is never been refreshed to latest value if the appointment is changed through exchange server.
Is there any solution for this issue? or other reason to make it happened?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有看到您其他代码,但您需要记住释放约会对象
Marshal.ReleaseComObject。
另外,您的客户端 Outlook 是否处于缓存模式?
马库斯
Not seeing you other code, but you need to remember to release the appointment objects
Marshal.ReleaseComObject.
Also is your client outlook in cache mode?
Marcus
我遇到了同样的问题,这是我的解决方案:
使用:
而不是:
区别是 Outlook.MAPIFolder 和 Outlook.Folder,我不知道为什么,但 Outlook.Folder 对我有用。
I've had same issue, and this is my solution:
Use:
Instead of:
The difference is Outlook.MAPIFolder and Outlook.Folder, I don't known why but Outlook.Folder works for me.