Genii Weblog

Save As Web Archive (single file, *.mht)

Mon 10 Nov 2003, 11:57 AM



by Ben Langhinrichs
"Imitation is the sincerest flattery." - C. C. Colton

One very cool feature in  Internet Explorer is the ability to save a web page with images and all intact into a single file.  It is very handy if you want to send information to which the recipient does not have full access, or if you want to save a whole page in case later changes to the website invalidate links or images.  Recently, I had a customer say, "Wouldn't it be cool if you could do that with a Notes document so that you could send the whole document with images and everything together to someone who doesn't have Notes?  Of course, you can do something similar with e-mail, but it doesn't preserve the integrity of the whole Notes document."

Well, like many good ideas, this one has been thought of before.  We actually added the ability to create *.mht files back in our Midas Rich Text LSX Version 2.50 in July 2002, but clearly not everybody knows about it, so here is a simple script that will take all selected documents and save them as *.mht files.  You can send these files to someone who doesn't have notes, and they can view them as if they were seeing the original Notes documents.

Sub Initialize
   ' *** Domino classes
   Dim s As New NotesSession
   Dim db As NotesDatabase
   Dim coll As NotesDocumentCollection
   Dim doc As NotesDocument
 
   ' *** Midas classes
   Dim rtitem As New GeniiRTItem
 
   Set db = s.CurrentDatabase
   Set coll = db.UnprocessedDocuments
   Set doc = coll.GetFirstDocument
   While Not (doc Is Nothing)
      Call rtitem.ConnectBackend(doc.Handle, "Body", True)
      Call rtitem.ExportToMIME("a:\" & doc.NoteID & ".mht","","","")
      Set doc = coll.GetNextDocument(doc)
   Wend 
End Sub

As usual with Midas, there are lots of options about how exactly you store the data, whether borders should be rendered as in Notes, etc.  As an example, with just a bit more code, you can save these as a collection, meaning that doclinks between the documents will continue to work between the *.mht files, giving you a set you can save on a CD or treat as an off-line data store with data integrity.  Let me know if you would like to see what you would need to add to make such a collection.

Copyright 2003 Genii Software Ltd.

What has been said:

No documents found