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.
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
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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…