|
|
Comments and Discussions
|
|
 |

|
Hi.. firstly, thanks for the code. Its exactly what we wanted. However we have one problem. Our dev and QA environments work under http and the code works fine for that but when the site runs under HTTPS(in UAT/LIVE environment), it throws following error:
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel
What I am doing is providing an HTML url for a file which gets created dynamically in the application folder (e.g. 'https://servername/Forms/PrintFiles/HTMLPage.html where 'servername' is the server where the site is hosted)
I will be thankful for any suggestions provided.
|
|
|
|

|
did you get a reply or work out a solution for this issue?
|
|
|
|

|
Actually, i'm having the same problem. Anyone has a clue?
|
|
|
|

|
I was looking for something like this. All I found was the commercial ones. I am currently saving the html only. although it works it will be nice to add the graphics.
cheers,
Donsw
My Recent Article : Organizational Structure within a Company for PMPs
|
|
|
|

|
In IE, when I save as MHTML, relative files are not embedded. If I have an HTML page with relative files, I save it as an mhtml, then remove the local files, I see no images in the mhtml. Am I doing something wrong. Is this how this code behaves? (Since it is supposed to mimic IE).
|
|
|
|

|
open the mht generate by this code with ms word, it shows error not a correct mht file, what's the problem?
|
|
|
|

|
The closing "--" seems to be missing after the last boundary
the last line :
------=_NextPart_000_00
should be :
------=_NextPart_000_00--
Then Word is happy
Edit: ups, just saw that this problem has already been fixed 5 years ago : Fixed it....well, to be honest, Kyle fixed it
modified on Monday, May 31, 2010 11:43 PM
|
|
|
|

|
Anyone know of something that will transform MHTML into HTML - I downloaded something from Softpedia that claimed to do it - but it doesn't produce any output!
TUT
If you up your bandwidth from slow DSL to fast DSL, make sure your shields are robust, you'll probably be visiting places you've not been before.
|
|
|
|

|
Anyone providing this code as an extension for Firefox 2?
I have been searching at length for a way to get this function into Firefox. Anyone know of a reliable add on for Firefox?
|
|
|
|

|
Can anyone help me get this working with Internet Explorer 7.0?
It doesn't throw an exceeption and saves the *.mht file.
The MHT file will not open in IE7.
If I go to the same website and "Save As" from Internet Explorer the MHT file opens OK.
I even tried the program against "http://www.codinghorror.com/blog/" and it again it save a MHT file that will not open in IE7.
Probably something simple but I can't figure it out...
|
|
|
|

|
we are using this piece of code for converting a lot of our reports which are in ASP to MHTML files which represents as an image of that week.
The problem we are facing is the MHTML file being generated is just adding a reference of all the images and CSS to our production site after archiving also. suppose the main site is down or we are offline then these webpage archived reports are not showing up properly, So any of you can you tell us some tweaking of this code to make it working.
Baladitya Ganty
|
|
|
|

|
This app works wonderfully with http:// based requests. However, if I try to use file:///... based requests, I get an invalid cast exception with with the WebClientEx.vb class on line 343:
Dim wreq As HttpWebRequest = DirectCast(WebRequest.Create(Url), HttpWebRequest)
Anyone have a work around? I'm not a guru with the HttpWebRequest.
I'm basically writing an application that dumps some information with charts to a html file and I would like to have it converted to .mht format for easy distribution.
|
|
|
|

|
Hi,
This is sort of an aside, but I figure that people who look at this page probably have a great familiarity with MHTML, and I need it to solve my problem. I have a webpage which contains a base64 string encoding a .png file. I also know the dimensions of the file etc. But the page will not know the image's URL.
I want to use this image as the background for one of the elements in my page. In Firefox/Safari/Opera, I can just use the "data: URI", i.e.
element.style.background-image = "url(data:image/png;base64," + base64String + ")";
Unfortunately, Internet Explorer does not support the data: URI. But I figure that IE must have this functionality, because it would be ridiculous if it didn't. And it looks to me like MHTML is the most likely way that one can get this done with IE.
Does anyone know if this is possible, and if so, could you please provide a short code snippet explaining how?
Thanks.
P1000
|
|
|
|

|
Its possible, as i've just had to write it
|
|
|
|

|
The mht generated looks fine (it's not all mungled up), but it won't load into ie7. Any thoughts? When you load the page, it's blank. the source in the browser is: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD> <BODY></BODY></HTML>
|
|
|
|

|
...Looking at you blog Jeff I found this post from Kyle who was talking about a fix to open the mht in word.
I applied the fix, and hey presto.
cheers
Moose
---------------------
Here's what Kyle said to do:
I've made two code changes to allow for the file to be opened in Word 2003. This made it work for me anyway.
Kyle
In builder.vb starting on line 474 change the procedure to the following:
Private Sub AppendMhtBoundary(Optional ByVal bEndOfFile As Boolean = False)
AppendMhtLine()
If bEndOfFile = False Then
AppendMhtLine("--" & _MimeBoundaryTag)
Else
AppendMhtLine("--" & _MimeBoundaryTag & "--")
End If
End Sub
In builder.vb on line 438, change procedure call to: AppendMhtBoundary(True)
Kyle on August 15, 2005 05:30 PM
|
|
|
|
|

|
Greetings,
Is it possible to embed java applets in mhtml files?
I tried adding to your code the applet tag and make it process the '.class' files but it doesn't seem to work. It only displays a blank page
Thanks.
|
|
|
|

|
Application is not working with 11S and Windows 2003 with localhost application. working fine with external websites and IIS 5.0 For example www.google.com is fine and localhost:8080\websitetest\test.aspx is not giving the correct result
|
|
|
|

|
I have a list of URL. How to make this going to be batched?
Seems that the whole process won't raise a "Finish" event..
|
|
|
|

|
It's like the genie granted me one wish and this was the result. It does exactly what I wanted and it's already in .Net format.
Superb!
|
|
|
|

|
Hi,
I am using your code to generate .Mht files. but at some sites, the generated .Mht files are opening in IE as text file. Can you please tell me why does it happen? is there any browser settings?
please help me out?
Thanks
Govind
|
|
|
|

|
I've got the same problem.
Wheras http://www.codinghorror.com/blog/ was saved successfully to mht
http://www.codeplex.com does not work correctly.
As Govind already said, only text/html-code will be displayed.
Any ideas?
Thx,
Christian
|
|
|
|

|
OK, problem solved!
It occurs when the subject of the mht archive is too long or includes linebreaks.
To solve the problem, only one line of code is affected to change:
Builder.VB 449
AppendMhtLine("Subject: " & ef.HtmlTitle)
Greetings
Christian
|
|
|
|

|
Hi,
Thank you very much for providing this well crafted code. I need to save html as "Web page complete", "Web page archive", "Web page as PDF" for an application to backup blogs. Currently I am doing it using your code . What I am interested in is to show the download progress as the web page is being saved. So I was thinking of combining the functions provided in MHT builder into the extended web browser control found at http://www.codeproject.com/csharp/ExtendedWebBrowser.asp.
I would request your help/guidance/indication/criticism on it.
S M Mahbub Murshed
|
|
|
|

|
Hello,
great job!! I've tried your library and I found it very usefull: my best compliments.
But I've found an error saving a particular web page: the url is "http://www.flcgil.it/notizie/news/2006/dicembre/firmato_il_contratto_di_lavoro_dell_enea_si_inizia_a_parlare_seriamente_dei_precari".
When I save the page, it gives me an exception: "System.IO.PathTooLongException: The path is too long after being fully qualified. Make sure path is less than 260 characters." But the url is 131 characters!
The exception is thrown saving the page in mht (with the method SavePageArchive, setting the file storage on disk as temporary or permanent) and in Web page complete (with SavePageComplete).
I suppose that during the saving, the library saves temporary html files where the name of the file, added to the url, exceeds 260 characters. If I'm right, the only solution is to give new shorter name to this temporary files.
Has anybody noticed this bug?
Thanks for your help!
Renato
|
|
|
|

|
I think I've fixed this bug.
I've noticed two reason for the failure in saving my page (http://www.flcgil.it/notizie/news/2006/dicembre/firmato_il_contratto_di_lavoro_dell_enea_si_inizia_a_parlare_seriamente_dei_precari):
1) this page probably references itself, so the recursively download of the externally referenced files never ends. Yes, there is a property AllowRecursiveFileRetrieval that I can set to false to avoid this, but I want to be sure to download all necessary files.
My idea is to permit the recursion only to a certain level of depth; reaching that limit, I suppose that the file is autoreferencing and I stop the recursive download. I've made the following changes in ExternalFile.vb:
Public Sub DownloadExternalFiles(ByVal st As Builder.FileStorage, ByVal level As Integer, Optional ByVal recursive As Boolean = False)
'test to avoid infinite recursion
level += 1
If level > 4 Then
recursive = False
End If
DownloadExternalFiles(st, Me.ExternalFilesFolder, level, recursive)
End Sub
Private Sub DownloadExternalFiles(ByVal st As Builder.FileStorage, ByVal targetFolder As String, ByVal level As Integer, ByVal recursive As Boolean)
Dim FileCollection As Specialized.NameValueCollection = ExternalHtmlFiles()
If Not FileCollection.HasKeys Then Return
Debug.WriteLine("Downloading all external files collected from URL:")
Debug.WriteLine(" " & Url)
For Each Key As String In FileCollection.AllKeys
DownloadExternalFile(FileCollection.Item(Key), st, targetFolder, level, recursive)
Next
End Sub
Private Sub DownloadExternalFile(ByVal url As String, ByVal st As Builder.FileStorage, _
ByVal targetFolder As String, ByVal level As Integer, Optional ByVal recursive As Boolean = False)
'... not changed
If isNew Then
'-- add this (possibly) downloaded file to our shared collection
_Builder.WebFiles.Add(wf.UrlUnmodified, wf)
'-- if this is an HTML file, it has dependencies of its own;
'-- download them into a subfolder
If (wf.IsHtml Or wf.IsCss) And recursive Then
wf.DownloadExternalFiles(st, level, recursive)
End If
End If
End Sub
In the file Builder.vb, in the functions SavePageComplete, GetPageArchive and SavePageArchive, when I call the method DownloadExternalFiles I initialize the depth of the recursion to zero:
_HtmlFile.DownloadExternalFiles(st, 0, _AllowRecursion)
2) When creating a new file name, it shouldn't be too long. This can happen expecially if the title of html page is used as file name. So I've modified the function MakeValidFilename in ExternalFile.vb:
Private Function MakeValidFilename(ByVal s As String, Optional ByVal enforceLength As Boolean = False) As String
If enforceLength Then
End If
'-- replace any invalid filesystem chars, plus leading/trailing/doublespaces
Dim name As String
name = Regex.Replace(Regex.Replace(s, "[\/\\\:\*\?\""""\<\>\|]|^\s+|\s+$", ""), "\s{2,}", " ")
'enforce the maximum length to 25 characters
If name.Length > 25 Then
Dim extension As String
extension = Path.GetExtension(name)
name = name.Substring(0, 25 - extension.Length) & extension
End If
Return name
End Function
(Maybe the optional parameter enforceLength was added to do something similar).
There is also a function MakeValidFilename in the file Builder.vb, but I can't see when it is called, so I haven't modified it.
With this changes, I can save my web page. Has anybody done something similar? Is there something I've missed?
Renato
|
|
|
|
|

|
Thanks dear for this cute artical and good class library , but my question now is if i publish my created presentation ( 3 slides for example ) to htm format from Microsoft PowerPoint and i tried to save it using your library , each time i clicked in any link in the htm presentation, the mht.dll saves only first slide
i think the problem results that the URL of the browser not changed even if i click in any link in the htm presentation, and the first file ( called fram.htm ) and this page contains first slide only URL , so the mht.dll detects only this slide page.
and i expect that the solution will be if i can save mht files from brwser cache ( like file save as in the browser)
i hope to help me in this problem
Thanks and Regards
Hammad
|
|
|
|
|

|
This is truly great work. Thanks a lot!
|
|
|
|

|
First of all thank you for the wonderful article and project. My question is not directly related to this project but I am posting it here in hope for getting some help. I am trying to write a proxy server to share internet connection. I know there are several small utilities available for this purpose but I wanted to do it my self so I can enhance it as I need. There is nice project (SSLProxy) at GotDotNet with source code but it is all in C# and I feel much comfortable using VB.NET. Also that project is pretty big to be converted to VB.NET. I wrote a small class using SOCKETS but it is not stable and sometimes it misses chunk of stream; especially when more then 2 connections are active.
Any help or suggestion is much appreciated.
syedhashmi@gmail.com
-- modified at 19:37 Saturday 22nd July, 2006
|
|
|
|

|
Before my contribution, I should state I enjoyed very much reading through the code !!!
I think I have found and fix two small bugs in the WebFile class.
Bug #1
The code wrongly assumes that the URL and <Base HREF=..> are identical. To fix it, I made three changes:
1) I added a private member to the class:
Private _BaseUrlFolder As String
2) _BaseUrlFolder is set in the ProcessHtml() method:
If BaseUrlFolder <> "" Then
If BaseUrlFolder.EndsWith("/") Then
_BaseUrlFolder = BaseUrlFolder.Substring(0, BaseUrlFolder.Length - 1)
Else
_BaseUrlFolder = BaseUrlFolder
End If
End If
3) _BaseUrlFolder is used in the ConvertRelativeToAbsoluteRefs() method
'-- href="/anything" to href="http://www.web.com/anything"
r = New Regex(urlPattern, _
RegexOptions.IgnoreCase Or RegexOptions.Multiline)
html = r.Replace(html, "${attrib}=${delim1}" & _BaseUrlFolder & "/${url}${delim2}")
'-- href="anything" to href="http://www.web.com/folder/anything"
r = New Regex(urlPattern.Replace("/", ""), _
RegexOptions.IgnoreCase Or RegexOptions.Multiline)
html = r.Replace(html, "${attrib}=${delim1}" & _BaseUrlFolder & "/${url}${delim2}")
'-- @import(/anything) to @import url(http://www.web.com/anything)
r = New Regex(cssPattern, _
RegexOptions.IgnoreCase Or RegexOptions.Multiline)
html = r.Replace(html, "${attrib} url(" & _BaseUrlFolder & "/${url})")
'-- @import(anything) to @import url(http://www.web.com/folder/anything)
r = New Regex(cssPattern.Replace("/", ""), _
RegexOptions.IgnoreCase Or RegexOptions.Multiline)
html = r.Replace(html, "${attrib} url(" & _BaseUrlFolder & "/${url})")
Bug #2
In the ProcessHtml method, removal of <base href=... > tag should be case insensitive and multiline. Code follows:
'-- remove the <base href=''> tag if present; causes problems when viewing locally.
Dim r As New Regex("<base[^>]*?>", RegexOptions.IgnoreCase Or RegexOptions.Multiline)
html = r.Replace(html, "")
r = Nothing
|
|
|
|

|
Generally correct but...
'-- href="/anything" to href="http://www.web.com/anything"
r = New Regex(urlPattern, _
RegexOptions.IgnoreCase Or RegexOptions.Multiline)
html = r.Replace(html, "${attrib}=${delim1}" & _BaseUrlFolder & "/${url}${delim2}")
'-- @import(/anything) to @import url(http://www.web.com/anything)
r = New Regex(cssPattern, _
RegexOptions.IgnoreCase Or RegexOptions.Multiline)
html = r.Replace(html, "${attrib} url(" & _BaseUrlFolder & "/${url})")
This is replacement of root-based relative url. So here should be used something like _BaseUrlRoot (getted same as you describe) instead of _BaseUrlFolder.
|
|
|
|

|
How can I Convert MHTML to HTML using c# or orther language?
|
|
|
|

|
I really want to know how to take multiple html files at once. is Me.url a array??
I Iuput "http://www.codeproject.com (ENTER) http://www.google.com" into the Target URL,but it show "unable to download 'http://www.codeproject.com/%0D%0Ahttp:/www.google.com': The remote server returned an error: (400) Bad Request."
How can I do??
Sorry,I know little about VB.NET and my English is terriable.
please help me~~
|
|
|
|

|
I was hoping to point this fantastic program at a URL and it will make each and every html file on that site into mht. It seems to take the index page only and then stops. It also saves the name as the title, rather than the actual file name...
I really like how this works but if this is able to do an entire site, and names the files using the actual file name rather than the title, could you let me know.
Perfect!
Sean of the Naki
|
|
|
|

|
This works for me (please post any improvements):
1. In WebClient.ex I added 2 functions ContentTypeFromExtension and IsBinaryFromExtension:
Private Function ContentTypeFromExtension(ByVal UrlExt As String) As String
Select Case UrlExt.ToLower
Case ".htm", ".html"
Return "text/html"
Case ".css"
Return "text/css"
Case ".gif"
Return "image/gif"
Case ".jpg", ".jpeg", ".jpe"
Return "image/jpeg"
Case ".bmp"
Return "image/bmp"
Case ".tif", ".tiff"
Return "image/tiff"
Case ".png"
Return "image/x-png"
Case ".xbm"
Return "image/x-xbitmap"
Case ".xpm"
Return "image/x-xpixmap"
Case ".xwd"
Return "image/x-xwindowdump"
Case ".djv", ".djvu"
Return "image/vnd.djvu"
Case ".js"
Return "text/javascript"
Case ".xml", ".xsl"
Return "text/xml"
Case ".xht", ".xhtml"
Return "application/xhtml+xml"
Case ".txt", ".asc"
Return "text/plain"
Case ".rtf"
Return "text/rtf"
Case ".rtx"
Return "text/richtext"
Case ".sgm", ".sgml"
Return "text/sgml"
Case ".avi"
Return "video/ms-video"
Case ".mpe", ".mpeg", ".mpg"
Return "video/mpeg"
Case ".wmv"
Return "video/x-ms-wmv"
Case ".mov", ".qt"
Return "video/quicktime"
Case ".movie"
Return "video/x-sgi-movie"
Case ".mxu"
Return "video/vnd.mpegurl"
Case ".ram", ".rm"
Return "audio/x-pn-realaudio"
Case ".ra"
Return "audio/x-realaudio"
Case ".mp2", ".mp3", ".mpga"
Return "audio/mpeg"
Case ".mid", ".midi"
Return "audio/midi"
Case ".wav"
Return "audio/x-wav"
Case ".aif", ".aifc", ".aiff"
Return "audio/x-aiff"
Case ".doc"
Return "application/msword"
Case ".xls"
Return "application/vnd.ms-excel"
Case ".ppt"
Return "application/vnd.ms-powerpoint"
Case ".flash", ".swf"
Return "application/x-shockwave-flash"
Case ".ipx"
Return "application/x-ipix"
Case ".pdf"
Return "application/pdf"
Case ".zip"
Return "application/zip"
Case ".bin", ".class", ".dll", ".dms", ".exe", ".lha", ".lzh", ".so"
Return "application/octet-stream"
Case ".dcr", ".dir", ".dxr"
Return "application/x-director"
Case Else
Return "text/html"
End Select
End Function
Private Function IsBinaryFromExtension(ByVal UrlExt As String) As Boolean
Select Case UrlExt.ToLower
Case ".htm", ".html", ".css", ".js", ".xml", ".xsl", ".xht", ".xhtml", ".txt", ".asc", ".rtf", ".rtx", ".sgm", ".sgml"
Return False
Case Else
Return True
End Select
End Function
2. Changed Sub GetUrlData:
'''
''' returns a collection of bytes from a Url
'''
''' URL to retrieve
Public Sub GetUrlData(ByVal Url As String, ByVal ifModifiedSince As DateTime)
Dim UrlExt As String
Dim wreq As WebRequest = DirectCast(WebRequest.Create(Url), WebRequest)
UrlExt = Path.GetExtension(Url)
'-- do we need to use a proxy to get to the web?
If _ProxyUrl <> "" Then
Dim wp As New WebProxy(_ProxyUrl)
If _ProxyAuthenticationRequired Then
If _ProxyUser <> "" And _ProxyPassword <> "" Then
wp.Credentials = New NetworkCredential(_ProxyUser, _ProxyPassword)
Else
wp.Credentials = CredentialCache.DefaultCredentials
End If
wreq.Proxy = wp
End If
End If
'-- does the target website require credentials?
If _AuthenticationRequired Then
If _AuthenticationUser <> "" And _AuthenticationPassword <> "" Then
wreq.Credentials = New NetworkCredential(_AuthenticationUser, _AuthenticationPassword)
Else
wreq.Credentials = CredentialCache.DefaultCredentials
End If
End If
wreq.Method = "GET"
wreq.Timeout = _RequestTimeoutMilliseconds
wreq.Headers.Add("Accept-Encoding", _AcceptedEncodings)
'-- sometimes we need to transfer cookies to another URL;
'-- this keeps them around in the object
If KeepCookies Then
If _PersistedCookies Is Nothing Then
_PersistedCookies = New CookieContainer
End If
End If
'-- download the target URL into a byte array
Dim wresp As WebResponse = DirectCast(wreq.GetResponse, WebResponse)
'-- convert response stream to byte array
Dim ebr As New ExtendedBinaryReader(wresp.GetResponseStream)
_ResponseBytes = ebr.ReadToEnd()
'-- determine if body bytes are compressed, and if so,
'-- decompress the bytes
Dim ContentEncoding As HttpContentEncoding
If wresp.Headers.Item("Content-Encoding") Is Nothing Then
ContentEncoding = HttpContentEncoding.None
Else
Select Case wresp.Headers.Item("Content-Encoding").ToLower
Case "gzip"
ContentEncoding = HttpContentEncoding.Gzip
Case "deflate"
ContentEncoding = HttpContentEncoding.Deflate
Case Else
ContentEncoding = HttpContentEncoding.Unknown
End Select
_ResponseBytes = Decompress(_ResponseBytes, ContentEncoding)
End If
'-- sometimes URL is indeterminate, eg, "http://website.com/myfolder"
'-- in that case the folder and file resolution MUST be done on
'-- the server, and returned to the client as ContentLocation
_ContentLocation = wresp.Headers("Content-Location")
If _ContentLocation Is Nothing Then
_ContentLocation = ""
End If
'-- if we have string content, determine encoding type
'-- (must cast to prevent Nothing)
_DetectedContentType = wresp.Headers("Content-Type")
If _DetectedContentType Is Nothing Then
_DetectedContentType = ""
Else
_DetectedContentType = ContentTypeFromExtension(UrlExt)
End If
If IsBinaryFromExtension(UrlExt) Then
_DetectedEncoding = Nothing
Else
If _ForcedEncoding Is Nothing Then
_DetectedEncoding = DetectEncoding(_DetectedContentType, _ResponseBytes)
End If
End If
End Sub
3. Maybe not necessary, because I added it before creating the functions in 1)
In External.vb:
3a. After Private _ContentType As String I added:
Private _ContentTypeBefore As String
3b. In Public Property URL() I added:
_ContentTypeBefore = ""
after
_ContentType = ""
3c. I changed the line:
_ContentType = _Builder.WebClient.ResponseContentType
into
_ContentTypeBefore = _Builder.WebClient.ResponseContentType
If _ContentTypeBefore = "application/octet-stream" Then
_ContentTypeBefore = "text/html"
End If
_ContentType = _ContentTypeBefore
3d. Because I don't know sh*t about regex constructions I changed Private Sub SetUrl into:
Private Sub SetUrl(ByVal url As String, ByVal validate As Boolean)
If validate Then
_Url = ResolveUrl(url)
Else
_Url = url
End If
'-- http://mywebsite
_UrlRoot = Regex.Match(url, "http://[^/'""]+", RegexOptions.IgnoreCase).ToString
If _UrlRoot = "" Then
_UrlRoot = Regex.Match(url, "file:///[^/'""]+", RegexOptions.IgnoreCase).ToString
End If
If _UrlRoot = "" Then
_UrlRoot = Regex.Match(url, "file:///[^\\'""]+", RegexOptions.IgnoreCase).ToString
End If
'-- http://mywebsite/myfolder
If _Url.LastIndexOf("/") > 8 Then
_UrlFolder = _Url.Substring(0, _Url.LastIndexOf("/"))
Else
_UrlFolder = _UrlRoot
End If
End Sub
3e. In Private Sub AddMatchesToCollection I added:
Dim urlRegex2 As New Regex("^files*:///\w+", RegexOptions.IgnoreCase)
and changed:
If Not urlRegex.IsMatch(value) Then
into:
If Not urlRegex.IsMatch(value) And Not urlRegex2.IsMatch(value) Then
Note:
I don't know what problems will arise by changing Sub GetUrlData.
- WebRequest/WebResponse instead of HttpWebRequest/HttpWebResponse
- Left out:
wreq.UserAgent = _HttpUserAgent
wreq.IfModifiedSince = ifModifiedSince
wreq.CookieContainer = _PersistedCookies
Hope the above works for you too.
Bye,
Ron
|
|
|
|

|
`please, any solution ?? any sample entire , please ??
thanks...
AE
|
|
|
|

|
We have an application for real-estate brokers, who receive every day new data concerning new real estate properties on the market.
Every day, they send this information to their prospects.
For this, they generate a HTML file and mail this as an attachment.
(I have created a HTML template file and the data is automatically merged, based on this template which results in a HTML file).
The problem was and still is, that they also want to show photos of the real estate properties.
I used to explain them that HTML is just plain text and if they want their recipients to see the photos, I would have to place hard references to the location of these photos (on their local server or after upload on their webserver).
For the real estate brokers, that use Outlook/Exchange I created a solution using the same generated HTML file mentioned above based on these articles (http://www.outlookcode.com/d/code/htmlimg.htm or http://www.dimastr.com/redemption/objects.htm).
For the other real estate brokers I was looking for a MHT(ML) solution using the same generated HTML file.
The name of this HTML file to be converted could have the following format:
file:///C:/Documents%20and%20Settings/ron.OMAWEB/Local%20Settings/Temp/PeriodiekAanbod/Obj_1506.html
The name of the photos could have the following format:
<img class="imgfoto" src="file:///C:\Documents%20and%20Settings\ron.OMAWEB\Local%20Settings\Temp\PeriodiekAanbod\Thumbnails\121313001211000w000649400000001000.jpg" alt="Cornelia van Arkeldijk 58" />
and also:
<img border="0" src="http://www.devilee.nl/images/devilee3.jpg" width="254" height="73" alt="Th. Devilee Makelaars">
You can see an example of the local HTML save in IE as a webarchive on:
http://home.wanadoo.nl/rsegijn/example.mht
You mentioned that at first you also supported local HTML files.
Could you please help me on my way?
I think I have to set some property UriScheme.File or UriScheme.Http
And based on this property use FileWebRequest and FileWebResponse or HttpWebRequest and HttpWebResponse.
And in case of a FileWebResponse set the Content-Type to "text/html", because FileWebResponse always returns "application/octet-stream".
And in Sub SetUrl match to "file:///[^/'""]+" and _Url.LastIndexOf("/") > 8 in case of UriScheme.File
And a lot of regex handling have to be adjusted (very interesting stuff, but I have NO idea what it does, even after reading a regex tutorial on the web .
etc.
etc.
Please help me on my way.
I have to find a solution this month.
Thanks in advance,
Ron Segijn
|
|
|
|

|
I forgot to mention 2 things:
1. I use a HTML template so that my customers can modify the html in their "office-style".
For example, the line in my previous message:
<img border="0" src="http://www.devilee.nl/images/devilee3.jpg" width="254" height="73" alt="Th. Devilee Makelaars">
is not in the original template, but added by one of my customers.
2. If you want to give me some hints or help me on my way, please also send it to me by email
ron@omaweb.nl and reply2me@wanadoo.nl
TIA,
Ron
|
|
|
|

|
Integrated your code into our application so that we could send MHT- formatted data to Interfax.Net for faxing -- it works great; thanks!! Next question is that we retain the MHT data in a database and would like to view it from inside the app -- with HTML, we simply write the text into the response object using Response.Write. For MHT data, this displays the MHT headers, etc. -- any idea what we're doing wrong? We think it might be as simple as setting the Response.ContentType or adding some headers, but we've not been able to find the magic combination that works... TIA -- john
|
|
|
|

|
Hi,
Can anyone advise whether it is possible to compile the MHT library to a dll for integrate in visual basic source code?
Thank you.
Jennifer Leongh
|
|
|
|

|
Appreciate your article, just what I was looking for.
Glad to see that someone else will claim to have the TI994A in their computer background. Taught myself assembly language for it, and even went as far as self publishing a technical manual for expanding it via the PEB, as well as demonstrating the only TI994A with a Motorola math coprocessor. But that is all in the basement now.
Anyway, great article and code!
|
|
|
|

|
hi
thx for that great code !
i need to save local html's generated by code into .mht files and i don't know how to proceed ..., even with CDO i didn't knwo how to do it, it seems like it takes only url's like ur code, i had a look at ur code didn't understand all but u r using regular expressions for that aim and i'm not good in regex
help please
thx in advance
C# is the future
|
|
|
|

|
This is great, just what I was looking for but I'm wondering what the license terms for this project ?
I notice that it says "© 2005, Atwood Heavy Industries, All Rights Reserved" when compiled and then there are not references to any kind of license terms, not in the code or in this article.
Would you consider releasing it under the LGPL ?
Thank you.
|
|
|
|

|
How is code this granular supposed to help anyone trying to do this? With how little help there is on converting to mHTML you'd think you'd give a more straightforward example, rather than a multi-class application that is tough to follow. Thanks for the help.......This isn't supposed to be a coding contest.
|
|
|
|

|
I had no problem using it.
|
|
|
|

|
Congratulations on a well written article and accessible code. I needed to be able to load the MHT into MS Word, so added a AppendFinalMhtBoundary routine to add the boundary with the trailing "--" as explained in another post. I also wanted the original URL of included graphics to be removed from the MHT, so I added a conversion to the <img src="cid:xyz"> format as is created by IE when doing Save As. I'm happy to share this if anyone is interested. Thanks for publishing!
|
|
|
|

|
Here's my situation, though. At my company, we send lots of HTML emails from different applications, processes, workflows, etc. Some of these emails include img tags, linking to our intranet. Since the Intranet server requires windows authentication, Windows XP SP2 pops up a login dialog whenever people open the email. Obviously, this is bad and people hate it... but they want the images and I don't want to have to collect all the generic and application specific images together in one folder just so I can turn on anonymous access for that folder to avoid the authentication prompt.
Another solution is to send the HTML emails as MHTML emails so that the pics are embedded. I've tried to pull your app apart, but it's VERY clear that you have put a mammoth amount of work in there and, to be honest, I'm not sure if it would be easier for me to try and write it myself.
Since you have done so much work and since you are the expert on your awesome app, can you enhance it so that I can pass in a string containing the full HTML and maybe a base URL path and receive the encoded MHTML as a response?
I certainly understand that you likely have more important things to do than solve my problems, but it'd be awfully great.
-Kevin Buchan
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A native .NET class for saving URLs: text-only, HTML page, HTML archive, or HTML complete.
| Type | Article |
| Licence | |
| First Posted | 12 Sep 2004 |
| Views | 312,885 |
| Bookmarked | 152 times |
|
|