VBA to open .msg saved to Hard Drive

tbakbradley

Board Regular
Joined
Sep 24, 2010
Messages
136
I have a need for a user to click a button that will run a Macro that opens an outlook .msg file saved to a specific location. It's an email template. Just needs to open that .msg file in outlook that already has the To Address and Subject and partial body they can alter.

I have code elsewhere in the spreadsheet that opens a Word Document saved to a specific location, but my searching to do the same for a .msg appears very complex and don't see why it can be simple like with Word, plus I can't follow some of the other examples I've seen.

Here is what I have to open a Word document stored somewhere.

Code:
Sub OpenWordDocument()
Set wordapp = CreateObject("word.Application")

    wordapp.documents.Open "[URL="file://\\ServerLocation\Folders\WordFile"]\\ServerLocation\Folders\WordFile[/URL].docx"

    wordapp.Visible = True
End Sub

Can something similar be done to open a .msg file saved to the same Server location?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I have a need for a user to click a button that will run a Macro that opens an outlook .msg file saved to a specific location. It's an email template. Just needs to open that .msg file in outlook that already has the To Address and Subject and partial body they can alter.

I have code elsewhere in the spreadsheet that opens a Word Document saved to a specific location, but my searching to do the same for a .msg appears very complex and don't see why it can be simple like with Word, plus I can't follow some of the other examples I've seen.

Here is what I have to open a Word document stored somewhere.

Code:
Sub OpenWordDocument()
Set wordapp = CreateObject("word.Application")

    wordapp.documents.Open "[URL="file://\\ServerLocation\Folders\WordFile"]\\ServerLocation\Folders\WordFile[/URL].docx"

    wordapp.Visible = True
End Sub

Can something similar be done to open a .msg file saved to the same Server location?


I got it working after more researching.

Sub OpenOutlookTemplate()
Dim myoutapp As Object
Dim myitem As Object
Set myoutapp = CreateObject("Outlook.Application")
Set myitem = myoutapp.CreateItemFromTemplate("\\SharedServer\Folder\*.msg")
myitem.Display
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top