lotus domino - NotesDocument.save() causing loss of rich text formatting -


i have following code in lotusscript agent removes attachments notesdocuments. notesdocument.save() causes loss of rich text formatting (font, color). there way retain formatting?

sub removeattachments_v2(doc notesdocument)     dim session notessession     dim rtitem variant     dim filename string     dim ans variant      set session = new notessession     dim richstyle notesrichtextstyle     set richstyle = session.createrichtextstyle     richstyle.notescolor = color_blue      if doc.hasembedded         set rtitem = doc.getfirstitem("body")         if (rtitem.type = richtext)             forall object in rtitem.embeddedobjects                 if (object.type = embed_attachment)                     filename = object.source                     call object.remove                     call rtitem.addnewline( 2 )                     call rtitem.appendstyle(richstyle)                     call rtitem.appendtext( "attachemnt removed: " & filename )                     call doc.save( true, true , true )                 end if             end forall         end if     end if end sub 

edit1: initialize function

sub initialize     dim db new notesdatabase("","")     dim col notesdocumentcollection     dim doc notesdocument      call db.open("", "c:\this\is\db\dir\test.nsf")     set col = db.alldocuments      set doc = col.getfirstdocument()     while not ( doc nothing )         call removeattachments_v2(doc)         call doc.save(false, false, false)         set doc = col.getnextdocument( doc )     wend end sub 

despite of fact, save document every attachment cannot find reason, why should happen. copied code in agent, , removes attachments desired , appends text in blue...

no formatting lost...

the error has somewhere else in code, in calling function.

old answer (wrong due own tests, kept here history):

the problem here is: defined rtitem variant. , getfirstitem gets notesitem instead of notesrichtextitem, when saving, converted "plain text" item.

most used variant instead of notesrichtextitem, because there mime- mails defining variable notesrichtextitem cause "type missmatch" or similar error. long not write ok.

as mime mails need complete different handling achieve goal, should first fix code pure notesrichtextitems using right type, , write code- branch handling mime- items


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -