PDA

View Full Version : [SOLVED:] .MSG Save As HTML



madwarren
08-30-2016, 09:08 AM
Hello. I'm a complete newbie to VB Script and was wondering if someone could help me out or at least give me some examples to work with. Any help would be greatly appreciated.

I would like to create a macro that will use the SAVE AS function and save an external .MSG file (that is on a network server) to an .HTML file in the same directory. There is a .MSG file in every project folder that I would like to convert automatically, rather than just opening and using the SAVE AS function within the options.

I plan on writing a batch file to run the macro once I get that figured out.


So every project has a .MSG with html structure that I would like to save as an .html file in the same directory as the .MSG file.

16976

Thanks for any help or just a push in the right direction!

gmayor
08-30-2016, 11:05 PM
You should be able to adapt the following to your requirements


Sub SaveMSG_as_HTML()
Dim olMsg As MailItem
Dim strPath As String
Dim strMsg As String
Dim strHTML As String
strPath = "C:\Path\"
strMsg = "filename.msg"
strHTML = Left(strMsg, InStrRev(strMsg, Chr(46))) & "html"
Set olMsg = Session.OpenSharedItem(strPath & strMsg)
olMsg.SaveAs Path:=strPath & strHTML, Type:=olHTML
olMsg.Close olDiscard
lbl_Exit:
Set olMsg = Nothing
Exit Sub
End Sub

madwarren
08-31-2016, 07:31 AM
Thanks a lot gmayor!