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?
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
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.
精彩评论