Ben Langhinrichs

November, 2014
SMTWTFS
      01
02 03 04 05 06 07 08
09 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30

Search the weblog





























Genii Weblog

To MIME and Back

Tue 11 May 2004, 09:32 AM



by Ben Langhinrichs
I had an interesting question from a customer.  He wants to use MIME to store his rich text, but wants to be able to edit the HTML part of the MIME using a third party web editor, so he needs to switch to HTML and switch back to MIME.  His needs were pretty simple in this regards, so I wrote a quick sample with two agents, which are below.  I wonder if I should make this even more robust and allow images in the MIME to be converted to attachments and modify the HTML accordingly.  It might be pretty handy for those who want to edit the rich text in the Notes client (as MIME) and the HTML on the web with a web editor, such as one of these.  Hmm.

Anyway, for those interested in how you would do this with Midas, here are the two agents.

'Convert HTML to MIME: 

Option Public
Option Declare
Uselsx
"*lsxrtc"

Sub Initialize
   ' *** Notes back-end class objects
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim collection As NotesDocumentCollection
   Dim doc As NotesDocument
   
   ' *** Midas Rich Text LSX back-end class objects
   Dim rtitem As GeniiRTItem
   
   ' *** Set up the database and collection
   Set db = session.CurrentDatabase
   Set collection = db.UnprocessedDocuments
   If collection.Count =Then Exit Sub
   
   ' *** Cycle through each selected document
   Set doc = collection.GetFirstDocument
   While Not (doc Is Nothing)
      ' *** Connect to rich text item with Midas 
      Set rtitem = New GeniiRTItem
      Call rtitem.ConnectBackend(doc.Handle, "Body", True)
      doc.Subject = doc.Subject(0) & "... to MIME"
      
      ' *** Save the HTML as  MIME part
      Call rtitem.SaveAsMime("Body", "", |Overwrite='Yes'|)
      
      Delete rtitem
      
      Set doc = collection.GetNextDocument(doc)
   Wend
End Sub


'Convert MIME to HTML: 

Option Public
Option Declare
Uselsx
"*lsxrtc"

Sub Initialize
   ' *** Notes back-end class objects
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim collection As NotesDocumentCollection
   Dim doc As NotesDocument
   
   ' *** Midas Rich Text LSX back-end class objects
   Dim rtitem As GeniiRTItem
   
   ' *** Set up the database and collection
   Set db = session.CurrentDatabase
   Set collection = db.UnprocessedDocuments
   If collection.Count =Then Exit Sub
   
   ' *** Cycle through each selected document
   Set doc = collection.GetFirstDocument
   While Not (doc Is Nothing)
      doc.Subject = doc.Subject(0) & "... to HTML"
      Call doc.Save(True, False)
      ' *** Connect to rich text item with Midas 
      Set rtitem = New GeniiRTItem
      
      ' *** Connect, copying in the HTML MIME part to the rich text
      Call rtitem.Connect(db.Server, db.FilePath, doc.NoteID, "Body", True, |CopyMIMEPart='HTML'|)
      Call rtitem.Save
      Delete rtitem
      
      Set doc = collection.GetNextDocument(doc)
   Wend
End Sub

Copyright © 2004 Genii Software Ltd.

What has been said:

No documents found