I want to convert msg files (in the local folder) to html in powershell. I have done this by using outlook but the problem is this script will work on server so I cant use outlook. So far, I have searched these questions:
- Save Email as MSG file without using Outlook (COM object, etc.) or 3rd party software
- convert msg to html in background using vbscript
- Read Outlook .msg File
I couldnt find many approaches with Powershell. However, with the help of the questions above I downloaded Redemption and used it like this:
$routlook = New-Object -COM Redemption.RDOSession
$routlook.Logon()
$msg = $routlook.GetMessageFromMsgFile("C:\temp\test.msg",$TRUE)
$path = "C:\temp\test.html"
$msg.HTMLBody | Set-Content $path
But $msg.HTMLBody just returns an empty html in the below and $msg.Body returns nothing:
<HTML>
<HEAD><META http-equiv=Content-Type content="text/html; charset=UTF-8">
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
</BODY></HTML>
Probably I am using Redemption in a wrong way and dont know how to fix it. Or is there any other 3rd party solution that can be used in servers rather than using outlook?
Thanks for any help