Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

generate mhtml

Status
Not open for further replies.

sharedworld

Programmer
Dec 25, 2003
65
US
I'm looking for a script to generate mhtml files (readed by IE or by MSWORD), which means that the pictures are included in the html file.

I know that CDO for NTS generate emails in the mhtml format, but I can't read the message before the actual sending (the getstream function works only on CDO, but not on CDO for NTS as far as I know)...

so i don't know what to do, please help me...
 
If you take a look to a mht file it shouldnt be hard to generate 1.
You have to compress all the binary data(pictures,swf movies etc) using base 64 and also replacing the links and so with the coresponding link dont forget the "3D" from the begining.
This is just as example, but i wonder why you would need a mht file?

________
George, M
 
I need a MHT file, because I wan't generate a DOC file for microsoft word, but on my host server I can't add any component (he dosen't even have microsoft word installed...) so now i'm creating html file and the user downloads it with the .doc extension and it's openned by word and automaticly layed out (because i'm playing around with special css tags that IE is ignoring but microsoft word is using it to lay out the file (you could see it when you export a doc file to html with the option (retain formatting), then when you open this htm file in word later it's coming back exactly like it was before on word.

My problem is, that in that way, the pictures are still located on my server, which means that the client must be connected to internet when he's opening the "word" file, so i found out a way which is to generate a mht file, then all the images are inside... with the word descriptions, but i don't know how to compress the images to the mht format, what is base 64, ans how can I compress it throuht asp?

I found a very nice component called chilkat mht, but it's not free...
 
Why not use this at the top of your actual HTML page.

Response.AddHeader "Content-type","application/msword"

With or without this line

Response.AddHeader "Content-Disposition","attachment; filename=page1.doc"

________
George, M
 
I did it already, but still my pictures aren't inside the doc file, so my customer must be connected to internet to open the "doc" file and view the pictures...
 
Ok now i understand then the only solution it's to write and mht as you sayed. The format it's simple. If you take a look, you would need also a base64 cripting function to cript binary data(pictures,sounds).

________
George, M
 
thank's shaddow but you know anything about how can I convert pictures to base64 format?
 
You would need an base64 cript algoritm.

________
George, M
 
Don't mean to butt in here, but...

If your next step is a component to encode binary data (such as images) in base64 you might try:


Look under "downloads." It is freeware but you have to supply an email address to get it. Spam, spam, spam, spam. Yeah, I know.

Bear in mind that base64 doesn't encrypt anything and rather than compressing data it actually works by expanding the data into a stream of printable characters. That's the whole point.

Microsoft does of course offer the free Office add-in "Web Archive" utility. This doesn't require Office at all, though it requires IE 4 or later (with Outlook Express installed) because it makes use of parts of OE to accomplish its task. There is an EXE here but it can't reliably be used by a server because though it is command-line driven it can pop up GUI dialogs and hang for user input. The EXE is just an interface to webarch.dll, but that DLL isn't ActiveX and script cannot use it directly.

I took a look at it hoping it might give you a one-stop way of creating your MHT files, but I guess not.

Good luck!
 
Oops!

At the link above click on "products" first. You might be happier.

"Downloads" takes you right to a form to select things to DL and "products" lets you browse descriptions first.

Sorry.
 
thanks dilletante, but i just wanna know how microsoft encodes those files, with which string? Let me expalain you what I want, if you check on the xstandard site, they are giving you an example to encode, like this:

Const otString = 2
Set objBase64 = Server.CreateObject("XStandard.Base64")
Response.Write objBase64.Encode("Hello World!", otString)

So, if i wan't encode pictures for an mhtml file, which 'otString' do I have to use? the same one?
 
All right dilletante, I just try with 2 as otString, it works for decoding an image encoded, but I don't know how to encode my pictures throught this component because when i'm opening the image with the filesystemobject component, he just can't read the file (only the first 4 or 5 chars, and i tryed a few pictures...), do you have any idea how to do this, we're really almost to the solution... thank's
 
Ok, i found myself the solution with adodb.stream, but if you have a faster solution to read binary, just tell me... thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top