using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CDO;
using ADODB;
namespace mhtConversion
{
public class MIMEConverter1
{
public static void CreateMHT(string urlHTML, string urlMHT)
{
CDO.Message objMessage = new Message();
objMessage.CreateMHTMLBody(urlHTML);
ADODB.Stream strm = new Stream();
strm.Type = StreamTypeEnum.adTypeText;
strm.Charset = "US-ASCII";
strm.Open();
var dsk = objMessage.DataSource;
dsk.SaveToObject (strm,"_Stream");
strm.SaveToFile(urlMHT, SaveOptionsEnum.adSaveCreateOverWrite);
strm.Close();
}
}
}
Wednesday, January 26, 2011
Create MHT from HTML in Powershell
$adSaveCreateNotExist = 1
$adSaveCreateOverWrite = 2
$adTypeBinary = 1
$adTypeText = 2
function SaveFileTo($msg,$mhtp){
$strm=New-Object -ComObject ADODB.Stream
$Strm.Type = $adTypeText
$Strm.Charset = "US-ASCII"
$Strm.Open()
$dsk=$msg.DataSource
$Dsk.SaveToObject($Strm, "_Stream")
$strm.SaveToFile($mhtp,$adSaveCreateOverWrite)
}
function createMHT($htmlPath,$mhtPath){
$objMessage= New-Object -ComObject CDO.Message
$objMessage.CreateMHTMLBody($htmlPath)
SaveFileTo $objMessage $mhtPath
}
createMHT "C:\Users\user\Desktop\sampleHtml\free small games.htm" "C:\Users\user\Desktop\sampleHtml\free small games.mht"
$adSaveCreateOverWrite = 2
$adTypeBinary = 1
$adTypeText = 2
function SaveFileTo($msg,$mhtp){
$strm=New-Object -ComObject ADODB.Stream
$Strm.Type = $adTypeText
$Strm.Charset = "US-ASCII"
$Strm.Open()
$dsk=$msg.DataSource
$Dsk.SaveToObject($Strm, "_Stream")
$strm.SaveToFile($mhtp,$adSaveCreateOverWrite)
}
function createMHT($htmlPath,$mhtPath){
$objMessage= New-Object -ComObject CDO.Message
$objMessage.CreateMHTMLBody($htmlPath)
SaveFileTo $objMessage $mhtPath
}
createMHT "C:\Users\user\Desktop\sampleHtml\free small games.htm" "C:\Users\user\Desktop\sampleHtml\free small games.mht"
Subscribe to:
Posts (Atom)
-
Objects are complex data type Const myObj = {}; console.log(myObj); const person = { firstName : ‘S’, lastName: ‘Man’, Age: 4 } person...
-
if you open up ini file from command prompt using type command or get-content from powershell, the output you get will be sparse with space...
-
$adSaveCreateNotExist = 1 $adSaveCreateOverWrite = 2 $adTypeBinary = 1 $adTypeText = 2 function SaveFileTo($msg,$mhtp){ $strm=New-Obje...