我有以下代码处理我从一个电子邮件拖放到一个表单文本框中的电子邮件。我遇到的问题是代码工作后拖放视觉实例的视觉冻结。我认为我需要以某种方式释放前景,但我不知道如何。
Private Sub frm_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles tbAppEmail.DragDrop
tbAppEmail.Text = String.Empty
Try
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
'supports a drop of a file from Windows Explorer
'Removed for visibility
ElseIf e.Data.GetDataPresent("FileGroupDescriptor") Then
'supports a drop of a Outlook message
'Dim objMI As Object - if you want to do late-binding
Dim objMI As Microsoft.Office.Interop.Outlook.MailItem
For Each objMI In objOL.ActiveExplorer.Selection()
'hardcode a destination path for testing
Dim strFile As String = _
IO.Path.Combine("\\ud1.utility\GSA\LWREPPLA\Databases_Dont_Touch\RTTEmails", _
(objMI.Subject + ".msg").Replace(":", ""))
tbAppEmail.Text += strFile + Environment.NewLine
objMI.SaveAs(strFile)
Next
End If
'tbAppEmail.Text = String.Empty
Catch ex As Exception
tbAppEmail.Text = "An error occured in the drop event" + Environment.NewLine + ex.ToString
End Try
End Sub
答案 0 :(得分:0)
尽量不要使用drop handler中的Outlook对象模型。请注意,FileGroupDescriptor将包含MSG格式的消息。