我编写了一个VSTO加载项,需要从Exchange服务器获取约会信息。
在交换(Outlook Web Access)上,我更改了约会的主题行。当我看到Outlook将主题行更改为新值时,我尝试以编程方式获取新值,并且大部分时间它都会获取旧值,而不是Outlook中显示的值。
我尝试使用.save函数处理 ItemChange 事件并保存项目,但似乎没有任何区别。
有人知道为什么我们一旦到达Outlook就不能以编程方式从Outlook约会中获取值?
现在有效的代码,非常难看,是一个很大的工作如下:
Public _idOfAppointmentCurrentlySyncing As New List(Of String)
Public _idOfAppointmentCurrentlySyncingNormal As New List(Of String)
Private Sub appointmentSave(ByVal Item As Object) Handles _m_olAppointment.ItemChange, _m_olAppointment.ItemAdd
Try
Dim dateNow As Date = Date.Now
If TypeOf Item Is Outlook.AppointmentItem Then
If (dateNow - _lastFolderSwitch).TotalMilliseconds > 3000 Then
Dim appointmentItem As Outlook.AppointmentItem = CType(Item, Outlook.AppointmentItem)
Dim lastModifiedDates As Date = commonToolsMethod.getAppointmentDateParameter(appointmentItem, "lastModifiedDates")
If _idOfAppointmentCurrentlySyncing.Contains(appointmentItem.EntryID) Then
Dim outlookLastSyncTime As Date = commonToolsMethod.getAppointmentDateParameter(appointmentItem, "OutlookLastSyncTime")
If outlookLastSyncTime <> Date.MaxValue And Date.Compare(lastModifiedDates, outlookLastSyncTime) <> 0 Then
commonTools.addPropertyToAppointment(appointmentItem, "lastModifiedDates", outlookLastSyncTime)
appointmentItem.Save()
Else
_idOfAppointmentCurrentlySyncing.Remove(appointmentItem.EntryID)
End If
Else
If _idOfAppointmentCurrentlySyncingNormal.Contains(appointmentItem.EntryID) = False Then
DebugWriter("Normal Save: " + appointmentItem.Start.ToString)
Try
If appointmentItem.Body <> "" Then
appointmentItem.Body += " "
End If
Catch ex As Exception
End Try
_idOfAppointmentCurrentlySyncingNormal.Add(appointmentItem.EntryID)
commonTools.addPropertyToAppointment(appointmentItem, "lastModifiedDates", dateNow.ToString)
appointmentItem.Save()
Marshal.FinalReleaseComObject(appointmentItem)
appointmentItem = Nothing
GC.Collect()
Else
_idOfAppointmentCurrentlySyncingNormal.Remove(appointmentItem.EntryID)
End If
End If
Else
_lastFolderSwitch = _lastFolderSwitch.AddMilliseconds(100)
End If
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
非常感谢提前。