如何从我的不在Outlook中的硬盘打开outlook .msg文件?

use*_*501 6 mailitem outlook-vba outlook-2013

我已经搜索了这个看似简单的任务的高低,但我遇到的所有引用都是保存到硬盘驱动器或从outlook文件夹中读取.

我有以下代码循环我的硬盘驱动器上的文件夹中的文件名,但我不知道如何采取该路径并使用Outlook打开它.

Dim inPath as String
Dim thisFile as String
Dim msg as MailItem
Dim OlApp as Object
Set OlApp = CreateObject("Outlook.Application")
inPath = "C:\temp"

thisFile = Dir(inPath & "\*.msg")
Do While thisFile <> ""
    'At this point, thisFile contains the path of a .msg like "C:\temp\mail_item1.msg"
    'msg = <open mailitem> <~~~~ HELP HERE
    'Do stuff with msg

    thisFile = Dir
Loop
Run Code Online (Sandbox Code Playgroud)

这个问题看起来很相似,但适用于C#,所以我在获取与我的问题相关的vba等效时遇到了一些麻烦.对于更熟悉outlook vba的人来说,这可能是显而易见的.

nit*_*ton 7

请看这里http://msdn.microsoft.com/en-us/library/office/ff865637.aspx

Sub CreateFromTemplate() 
 Dim MyItem As Outlook.MailItem 
 Set MyItem = Application.CreateItemFromTemplate("C:\statusrep.oft") 
 MyItem.Display 
End Sub 
Run Code Online (Sandbox Code Playgroud)

不只是针对.oft文件

Set MyItem = Application.CreateItemFromTemplate("C:\temp\mail_item1.msg")
Run Code Online (Sandbox Code Playgroud)

编辑 - 我一直忘记OpenSharedItem. http://msdn.microsoft.com/en-us/library/office/bb208171(v=office.12).aspx