メールアイテムをドロップできるコントロールがあり、正常に動作しますが、選択/アイテムをクリアすることができません。
例:メール1->メール1がリストにあるメール1をリストから削除してOutlookに戻り、メール2をドラッグアンドドロップします。メール
2がリストに表示されますが、メール1も復活します。についての投稿をたくさん見つけましたが、Marshal.ReleaseComObject
私はそれを正しい方法でやっていないと思いますか?
仕様:VS2010、4.0フレームワーク。Windows 7 OS、Outlook 2010
これが私のコードの一部です:
私のメソッドの呼び出しSave
:
ElseIf e.Data.GetDataPresent("FileGroupDescriptor") Then
Try
Dim SafeSaveMethod As New dlgCallSaveMails(AddressOf SaveMailsFromSelection)
Me.BeginInvoke(SafeSaveMethod, Me.FileData.Pad)
Save
方法:
Private Sub SaveMailsFromSelection(_path As String)
' File uit Outlook
Dim x As Integer
Dim xitmndx As Integer = 0
Dim DestFile As String
Dim oOutLook As New Outlook.Application
Dim oExplorer As Outlook.Explorer
Dim oSelection As Outlook.Selection
Dim strFile As String
oExplorer = oOutLook.ActiveExplorer
oSelection = oExplorer.Selection
Dim currentFolder As MAPIFolder = oExplorer.CurrentFolder
Dim folders As Folders = currentFolder.Folders
Try
For Each mitem As Object In oSelection
xitmndx += 1
Dim mi As Microsoft.Office.Interop.Outlook.MailItem = TryCast(mitem, Microsoft.Office.Interop.Outlook.MailItem)
mi.SaveAs(_path & "\" & String.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", mi.CreationTime) & "-" & CleanInput(mi.Subject) & ".msg", Outlook.OlSaveAsType.olMSG)
Marshal.ReleaseComObject(mi)
mi = Nothing
Next
Catch ex As System.Exception
WriteError2EventLog("Error picDropZone_DragDrop 4: " & ex.ToString)
MsgBox(Err.Description, MsgBoxStyle.Exclamation, "mycontrol")
Finally
Marshal.ReleaseComObject(oExplorer)
Marshal.ReleaseComObject(oSelection)
Marshal.ReleaseComObject(currentFolder)
Marshal.ReleaseComObject(folders)
Marshal.FinalReleaseComObject(oExplorer)
End Try
End Sub
私も試しoExplorer.ClearSelection()
ましたが、countプロパティからわかるように、まったくクリアされません