我在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