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

查看:22
本文介绍了如何从不在 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:	emp"

thisFile = Dir(inPath & "*.msg")
Do While thisFile <> ""
    'At this point, thisFile contains the path of a .msg like "C:	empmail_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:	empmail_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天全站免登陆