473,507 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about save html file as mht file

Hi,

I found a vbs file on the internet, it can do this job very well:
------------------
'MakeMHT.vbs

Const adSaveCreateNotExist = 1
Const adSaveCreateOverWrite = 2
Const adTypeBinary = 1 'Binary data
Const adTypeText = 2 '(Default) Text data

URL = "http://ideas.live.com/mainpage.aspx"
DiskFile = "C:\test.mht"

Set objMessage = CreateObject("CDO.Message")
objMessage.CreateMHTMLBody URL
SaveToFile objMessage, DiskFile

Sub SaveToFile(Msg, Fn)
Dim Strm, Dsk
Set Strm = CreateObject("ADODB.Stream")
Strm.Type = adTypeText
Strm.Charset = "UTF-8"
Strm.Open
Set Dsk = Msg.DataSource
Dsk.SaveToObject Strm, "_Stream"
Strm.SaveToFile Fn, adSaveCreateOverWrite
End Sub
------------------
But I want to do it in my C# application, the following is my code:

public static void WBSaveAsMHT(ref AxSHDocVw.AxWebBrowser webBrowser, string
fileName)
{
CDO.Message msg = null;
CDO.Configuration config = null;
ADODB.Stream stream = null;
string url = null;
if(webBrowser == null)
{
throw new Exception("The webbrowser control is null.");
}
try
{
url = webBrowser.LocationURL;
msg = new CDO.MessageClass();
config = new CDO.ConfigurationClass();

msg.Configuration = config;
msg.CreateMHTMLBody(url, CDO.CdoMHTMLFlags.cdoSuppressNone, "", "");

stream = new ADODB.StreamClass();
stream = msg.GetStream();
stream.SaveToFile(fileName,
ADODB.SaveOptionsEnum.adSaveCreateOverWrite);
}
catch(Exception ex){...}
}

My code can download and create MHT file, but when I open the MHT file in
IE, the images cannot be displayed. I have opened the MHT file in notepad
and found the images were actually downloaded and achieved. I don't know
what's wrong in my c# code.

Any help would appreciate!
Mar 7 '06 #1
0 2239

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
11447
by: LG | last post by:
Just have a question with regards to the clipboard, and how to read what other applications (Adobe InDesignCS) place in the clipboard. I am currently in the process of creating a booklet from a...
0
6412
by: a | last post by:
Save text file as html kloepper 17:42 23 Jul '04 I'm using httpwebresponse and a StringBuilder to return a stream that originates as a file with the .txt suffix (My download code converts the html...
4
4511
by: Jae | last post by:
I'm writing a web application that exports and imports excel files. The application gets a list of users and their info and displays it in a datagrid .The user then selects to save the file as a...
3
1056
by: Buddy Ackerman | last post by:
This is not an ASP.NET specific question, more of a generic HTML question. I want to provide users a link (or a button or some control) that they can click on to download a file. The trick is that...
2
1190
by: VB Programmer | last post by:
My client wants to make an HTML newsletter (using Word) then upload it to my website. I know how to send emails using system.web.mail. How do I make the HTML (of the file) the body contents,...
6
1044
by: MPR | last post by:
Hi guys; I got HTML code assigned to a variable. Actually what I got into the variable is the whole HTML code for a web page. I want to save that HTML code to disk, but not as HTML, I wan to...
1
2117
by: Marko Vuksanovic | last post by:
I used the following code for implementing a file upload progress indicator, using UpdateProgress Panel, though I have a problem that FileUpload.Has File always returns false. Any suggestions what...
3
8553
by: fiefie.niles | last post by:
I would like to save a web page to a file and have the hyperlinks work when I bring the file back up. If the web page has a hyperlink like the following <a href="OurWeb/News/abcFile.htm">, after...
7
3371
by: glbdev | last post by:
I have aspnet code (C#) to create a Crystal Report and export to pdf (in browser) without a Crystal Report Viewer. Works great except when the user attempts to save the file from the browser. ...
29
2195
by: Brad Pears | last post by:
Here is a simple OO design question... I have a Contract class. The user can either save an existing contract or they start off fresh with a blank contract, fill in the data and then save a...
0
7109
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7481
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.