我在lotusscript代理程序中删除了附件从NotesDocuments中的以下代码。但NotesDocument.save()会导致富文本格式(字体,颜色)丢失。有什么方法可以保留格式吗?NotesDocument.save()导致富文本格式丢失
Sub removeAttachments_v2(doc As NotesDocument)
Dim session As NotesSession
Dim rtitem As Variant
Dim filename As String
Dim ans As Variant
Set session = New NotesSession
Dim richstyle As NotesRichTextStyle
Set richstyle = session.CreateRichTextStyle
richstyle.NotesColor = COLOR_BLUE
If doc.HasEmbedded Then
Set rtitem = doc.getfirstitem("Body")
If (rtitem.type = RICHTEXT) Then
ForAll object In rtitem.EmbeddedObjects
If (object.Type = EMBED_ATTACHMENT) Then
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:初始化函数
Sub Initialize
Dim db As New NotesDatabase("","")
Dim col As NotesDocumentCollection
Dim doc As NotesDocument
Call db.Open("", "C:\this\is\db\dir\test.nsf")
Set col = db.Alldocuments
Set doc = col.Getfirstdocument()
While Not (doc Is Nothing)
Call RemoveAttachments_v2(doc)
Call doc.Save(False, False, False)
Set doc = col.GetNextDocument(doc)
Wend
End Sub
您对NotesSesion.ConvertMIME属性的设置是什么? –
NotesSession.ConverMIME为True – PrashantB