I searched high and low for this seemingly simple task, but all the links that I encounter are either stored on the hard drive or read from the Outlook folder.
I have the following code that iterates over the file names in a folder on my hard drive, but I donβt know how to take this path and open it using 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
This question was similar, but was for C #, so I was having problems getting the vba equivalent associated with my problem. Maybe this will be obvious to someone more familiar with Outlook vba.
See here 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
Not just for .oft files
Set MyItem = Application.CreateItemFromTemplate("C:\temp\mail_item1.msg")
Edit - I forget about OpenSharedItem all the time. http://msdn.microsoft.com/en-us/library/office/bb208171(v=office.12).aspx
Source: https://habr.com/ru/post/989328/More articles:Open Outlook Mail.msg file with VBA from Excel - vbaI need to encode the correct "link" to MS Outlook from Excel - vbahttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/989325/how-to-ask-docker-to-pull-from-private-repository-when-building&usg=ALkJrhja6kIoBEtHMvBWGabVTqXWf44UVAForwarding a non-type argument causes different behavior in the variable template - c ++Attempting to open an Outlook email template with excel VBA - vbaCreate / Open existing msg from path to new Outlook.MailItem in C # - c #https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/989330/how-do-i-merge-between-multiple-forked-repositories-on-github&usg=ALkJrhhCVKa9mio9U4BJKK-uRbGNAnu7lgThe fastest way to determine if a double is finite? - c #what does "->" mean quick expression when declaring functions? - iosHow to dynamically create an environment variable? - powershellAll Articles