首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Outlook拖放.msg错误

Outlook拖放.msg错误
EN

Stack Overflow用户
提问于 2016-03-04 20:46:37
回答 1查看 430关注 0票数 0

我有下面的代码处理我的拖放电子邮件从outlook到一个表单文本框。我遇到的问题是,在代码正常工作后,拖放outlook的实例会在视觉上冻结。我想我需要以某种方式发布outlook,但我不确定如何发布。

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2016-03-04 22:08:29

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35796473

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档