如何从不在Outlook中的硬盘驱动器中打开Outlook .msg文件? [英] How do I open an outlook .msg file from my harddrive that is NOT in outlook?

查看:400
本文介绍了如何从不在Outlook中的硬盘驱动器中打开Outlook .msg文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have searched high and low for this seemingly simple task, but all references I come across are either saving to the hard-drive or reading from an outlook folder.

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

I have the following code that loops through file names in a folder on my hard-drive, but I do not know how to take that path and open it with 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

此问题看起来很相似,但用于C#,因此在获取与我的问题相关的vba等效项时遇到了一些麻烦.也许对更熟悉Outlook vba的人来说是显而易见的.

This question looked similar but was for C#, so I had some trouble getting the vba equivalent related to my problem. Maybe it will be obvious to someone more familiar with outlook vba.

推荐答案

请参阅此处 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 

不仅适用于.oft文件

Not just for .oft files

Set MyItem = Application.CreateItemFromTemplate("C:\temp\mail_item1.msg")

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

Edit - I keep forgetting about OpenSharedItem. http://msdn.microsoft.com/en-us/library/office/bb208171(v=office.12).aspx

这篇关于如何从不在Outlook中的硬盘驱动器中打开Outlook .msg文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆