我有下面的代码处理我的拖放电子邮件从outlook到一个表单文本框。我遇到的问题是,在代码正常工作后,拖放outlook的实例会在视觉上冻结。我想我需要以某种方式发布outlook,但我不确定如何发布。
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发布于 2016-03-04 22:08:29
尽量不要在拖放处理程序中使用Outlook对象模型。注意,FileGroupDescriptor将包含MSG格式的消息。
https://stackoverflow.com/questions/35796473
复制相似问题