Targeted
Navigation:

Technology All The Way
Iodid Weblogs
 

Standard
Navigation:

Home
FAQ
Search
Table of Contents

Email:

TryandGuess
-at-
iodid.com

Search this weblog:


Visitor Count:
Money Grubbing:

Amazon Honor System Click Here to Pay Learn More

Terms of Use

October 21, 2003

Saveas MTH file

I want to download and programatically save web pages as mht files. I was having a hard time until I went to IE SaveAS MHTML in C#, where I found the following code:

Make a reference to these two COM objects:
C:\WINDOWS\SYSTEM32\cdosys.dll
C:\Program Files\Common Files\System\ado\msado15.dll

I don't think neither of these have PIAs (Primary Interop Assembly) so this will generate two typelibs for your project.

The Source:

CDO.MessageClass message = new CDO.MessageClass();
message.CreateMHTMLBody("http://www.fanms.com/", CDO.CdoMHTMLFlags.cdoSuppressNone, "", "");

ADODB.Stream stream = message.GetStream();
stream.SaveToFile("fanms.mht", ADODB.SaveOptionsEnum.adSaveCreateOverWrite);

Now I just have to change it to VB.

Update: Here is my version of this code in VB:

Dim message As New CDO.MessageClass()
message.CreateMHTMLBody("http://www.iodid.com", CDO.CdoMHTMLFlags.cdoSuppressNone, "", "")

Dim Outstream As ADODB.Stream
Outstream = message.GetStream
Outstream.SaveToFile("c:\test.mht", ADODB.SaveOptionsEnum.adSaveCreateOverWrite)

Posted by tmichael at 03:44 PM | Comments (3)

CDOSYS.dll missing

As I worked to convert the c# info in my post about saving a web page as an mht file, I ran into a problem with the reference to cdosys.dll.

A little research brought me to this page:

318823 - CDO for Windows 2000 Library Reference Is Unavailable in Visual Basic Project

There I learned:

If you try to create or modify a project that references the Microsoft Collaboration Data Objects for Windows 2000 (CDOSYS) Library, the reference is not available. The reference for the Microsoft Collaboration Data Objects (CDO) for Exchange 2000 Library is present instead.

So the quest continues.

Posted by tmichael at 04:01 PM | Comments (1)