【问题标题】:Outlook drag and drop .msg errorOutlook拖放.msg错误
【发布时间】: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


    【解决方案1】:

    尽量不要使用放置处理程序中的 Outlook 对象模型。请注意,FileGroupDescriptor 将包含 MSG 格式的消息。

    【讨论】:

    猜你喜欢
    • 2012-06-02
    • 1970-01-01
    • 2010-12-21
    • 2016-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多