我已经搜索了这个看似简单的任务的高低,但我遇到的所有引用都是保存到硬盘驱动器或从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的人来说,这可能是显而易见的.
我想运行一些代码Excel,与之对话Outlook.在我的机器上,我可以从Tools->ReferencesVBE中选择正确的参考.
但我希望我的代码也可以在他们的机器上为其他用户运行,他们都有不同版本的Outlook和Excel,
有没有一种整洁的方法我可以让代码选择正确的MS Outlook引用,或告诉我是否没有安装Outlook等?
谢谢