我能找到兩種解決我的問題,#1正在爲我和#2不可接受我實際使用:
解決方案#1:使用註冊表項,以對外接關機和重新禁用Exchange服務器 - 在插件啓動時啓用它。以下是示例代碼:
Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
Try
Dim regTopKey As String = "HKEY_CURRENT_USER"
Dim regPath As String = "\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\13dbb0c8aa05101a9bb000aa002fc45a"
Dim oldValue As Byte() = Registry.GetValue(regTopKey & regPath, "00036601_Backup", Nothing)
If oldValue IsNot Nothing Then
Registry.SetValue(regTopKey & regPath, "00036601", oldValue, RegistryValueKind.Binary)
End If
Catch
End Try
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
Try
Dim disableExchangeMode As Byte() = {4, 0, 0, 0}
Dim regTopKey As String = "HKEY_CURRENT_USER"
Dim regPath As String = "\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\13dbb0c8aa05101a9bb000aa002fc45a"
Dim currentValue As Byte() = Registry.GetValue(regTopKey & regPath, "00036601", Nothing)
If currentValue IsNot Nothing Then
Registry.SetValue(regTopKey & regPath, "00036601_Backup", currentValue, RegistryValueKind.Binary)
End If
Registry.SetValue(regTopKey & regPath, "00036601", disableExchangeMode, RegistryValueKind.Binary)
Catch
End Try
End Sub
解決方案2:檢測用戶何時更改約會項目並將更改保存在用戶定義的屬性字段中。下面是示例代碼:
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 > 500 Then
_lastFolderSwitch = dateNow
Dim appointmentItem As Outlook.AppointmentItem = CType(Item, Outlook.AppointmentItem)
If (dateNow - appointmentItem.LastModificationTime).TotalMilliseconds < 100 Then
Dim lastModifiedDate As Outlook.UserProperty = appointmentItem.UserProperties.Add("lastModifiedDate", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText, True)
lastModifiedDate.Value = dateNow.ToString
appointmentItem.Save()
End If
End If
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
謝謝大家,幫
MMB我沒有得到這個...你還有什麼在Outlook中運行。 – 76mel 2010-02-22 17:45:23
76mel,我也不明白,爲什麼我問這個問題。我還有幾個在Outlook中運行的addIns,我嘗試禁用所有這些,但它沒有改變。 – 2010-02-22 20:10:30
我在頂部的描述中添加了關於我的問題性質的更多解釋。 – 2010-02-22 20:27:56