cipheremix cipheremix - 1 year ago 61
C# Question

VSTO outlook data issue through exchange sync

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:


  1. click button, get LastModificationTime as "time1"

  2. change start date as "start1" in my mobile phone, sync to outlook through exchange server

  3. click button, get LastModificationTime, still "time1"

  4. change start date as "start2" in outlook, but the appointment is still in "start1" date.

  5. restart outlook

  6. click button, get new LastModificationTime as "time2", and appointment is in "start1" date, "start2" is gone.



steps without issue


  1. click button, get LastModificationTime as "time1"



1.1. restart outlook


  1. change start date as "start1" in my mobile phone, sync to outlook through exchange server

  2. 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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download