[英]Drag and drop from outlook to winform
引用Microsoft.Office.Interop.Outlook.dll
,这是一种非常简单明了的方法,没有第三方代码,可以从Outlook信息中获取删除的项目:
Imports Microsoft.Office.Interop
.....
Private Sub MainForm_DragEnter(sender As Object, e As DragEventArgs) Handles Me.DragEnter, TextBox1.DragEnter
DragStart = True
End Sub
Private Sub MainForm_DragOver(sender As Object, e As DragEventArgs) Handles Me.DragOver, TextBox1.DragOver
If DragStart Then
If e.Data.GetFormats.Contains("Csv") OrElse e.Data.GetFormats.Contains("CSV") Then
e.Effect = DragDropEffects.Copy
End If
End If
DragStart = False
End Sub
Private Sub GetFromOutlook()
Dim myOlApp As New Outlook.Application
Dim myExp As Outlook.Explorer = myOlApp.ActiveExplorer
Dim myMailItem As Outlook.MailItem = DirectCast(myExp.Selection.Item(1), Outlook.MailItem)
' (with debug) you can check other properties
'For Each ipp As Outlook.ItemProperty In myMailItem.ItemProperties
' Dim x1 = ipp.Name
' Dim x2 = ipp.Value
'Next
Const PR_TRANSPORT_MESSAGE_HEADERS = "http://schemas.microsoft.com/mapi/proptag/0x007D001F"
Const PR_MAIL_HEADER_TAG = "http://schemas.microsoft.com/mapi/proptag/0x007D001E"
Dim oPA As Outlook.PropertyAccessor = myMailItem.PropertyAccessor 'As Outlook.PropertyAccessor
Dim Header As String = oPA.GetProperty(PR_MAIL_HEADER_TAG)
Dim messageBody = myMailItem.Body
myExp = Nothing
myMailItem = Nothing
myOlApp = Nothing
'
' ......enter your code here
'
End Sub
您仍然可以使用OOM-只要确保您使用的是您决定支持的最低版本的Outlook中的互操作即可。 或者,您可以使用后期绑定并通过反射进行所有操作。
您还可以使用Redemption及其RDOSession.GetMessageFromMsgFile方法-它在所有版本的Outlook(直到2013年一直使用97)中都可以使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.