【发布时间】:2016-06-18 05:07:00
【问题描述】:
我有以下代码处理我的电子邮件从 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
【问题讨论】:
标签: vb.net outlook drag-and-drop