Consulting

Results 1 to 3 of 3

Thread: .MSG Save As HTML

  1. #1

    Question .MSG Save As HTML

    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.

    1.JPG

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

  2. #2
    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
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    Thanks a lot gmayor!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •