I have a rich text field I want to copy (Append) which is stored in multiple parts in a document as seen here:
How can I copy all the parts? I tried the following but it doesn’t seem to work. It only goes through the loop once, not the 5 times as I had hoped.
. .Dim s As New NotesSession
. .Dim thisDB As NotesDatabase
. .
. .Dim dc As NotesDocumentCollection
. .
. .Dim thisDoc As NotesDocument
. .Dim EmailDoc As NotesDocument
. .Dim ButtonDoc As NotesDocument
. .
. .Dim EmailBody As NotesRichTextItem
. .Dim TheButton As NotesRichTextItem
. .Dim TheButtonI As NotesItem
. .
. .Dim searchstring As String
. .Dim c As Integer
. .
. .Dim t As Variant
. .
. .Set thisDB = s.CurrentDatabase
. .Set thisDoc = Source.Document
. .Set EmailDoc = thisDB.CreateDocument
. .
. .If thisDoc.SentAlready(0) = “N” Then
. . . .thisDoc.SentAlready=“Y”
. . . .Call thisDoc.Save(False,False)
. . . .With EmailDoc
. . . . . …Form=“Memo”
. . . . . …SendTo=“Stephen M Christian/BUS/ORG”
. . . .End With
. . . .
. . . .Set EmailBody = New NotesRichTextItem (EmailDoc, “Body”)
. . . .searchstring = |SELECT FORM=“ButtonHolder”|
. . . .
. . . .Set dc = thisDB.search(searchstring, Nothing,0)
. . . .If (dc.count = 1) Then
. . . . . .Set ButtonDoc = dc.GetNthDocument(1)
. . . . . .Call EmailBody.AddNewline(2)
. . . . . .c=0
. .’ Warning After this point do NOT resave TheButtonDoc
. . . . . .Set TheButtonI = ButtonDoc.GetFirstItem(“TheButton”)
. . . . . .Do Until TheButtonI Is Nothing
. . . . . . . .Call EmailBody.AppendRTItem(TheButtonI)
. . . . . . . .c=c+1
. . . . . . . .'Call ButtonDoc.RemoveItem(“TheButton”)
. . . . . . . .Call TheButtonI.Remove
. . . . . . . .Set TheButtonI = ButtonDoc.GetFirstItem(“TheButton”)
. . . . . .Loop
. . . . . .Call EmailBody.AddNewline(2)
. . . . . .Call EmailBody.AppendText(“This is a test.”)
. . . . . .Call EmailBody.AddNewline(2)
. . . .End If
. . . .
. . . .EmailDoc.Subject = “Button Version 3.0 Alpha loop=[” & Cstr(c) & “].”
. . . .Call EmailDoc.Send(False,EmailDoc.SendTo(0))
. . . .Set EmailDoc = Nothing
. .End If