How to copy multipart Field (e.g. Rich Text or $File)

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

Subject: How to copy multipart Field (e.g. Rich Text or $File)

Although you see the item 5 times in the document properties the item really only occurs once for your programming purposes.

This is, as a matter of fact, standard behaviour for RichText items.

You only need to do one AppendRTItem and Notes/Domino should automagically create as many instances of the item as needed.

Subject: RE: How to copy multipart Field (e.g. Rich Text or $File)

Thanks Kenneth, but I don’t seem to be getting the hope for result.

Any and all ideas are welcome!! I assume my issue is the fact I’m using GetFirstItem but I’m missing what to use instead of GetFirstItem? Am I missing something obvious?

When I try the code below I get just 2 body fields (not 5 or more), in the e-mail

When I try to open this e-mail I get the error message: (warning: Ignoring portion of the document, that…)

I assume this is because I’m getting a fragment vs the entire richtext item.

The only way I seem to have any luck is to use the CopyAllItems then I see the 5 lines of TheButton:

For the code I tried both NotesItem and NotesRichTextItem to see if it made any difference.

. .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/CEG/CSC”

. . . .End With

. . . .

. . . .Set EmailBody = New NotesRichTextItem (EmailDoc, “Body”)

. . . .searchstring = |SELECT FORM=“ButtonHolder”|

. . . .

. . . .Call EmailBody.AppendText(“vvvv ---- Before ---- vvvv”)

. . . .Call EmailBody.AddNewline(2)

. . . .

. . . .Set dc = thisDB.search(searchstring, Nothing,0) . . . .

. . . .If (dc.count = 1) Then

. . . . . .Set ButtonDoc = dc.GetNthDocument(1)

. . . . . .Set TheButton = ButtonDoc.GetFirstItem(“TheButton”)

’ . . . . . .Set TheButtonI = ButtonDoc.GetFirstItem(“TheButton”)

. . . . . .Call EmailBody.AppendRTItem(TheButton) . . . . . .

’ . . . . . .Call EmailBody.AppendRTItem(TheButtonI)

. . . .End If

. . . .

. . . .Call EmailBody.AddNewline(2)

. . . .Call EmailBody.AppendText(“^^^^ ---- After ---- ^^^^”)

. . . .

. . . .EmailDoc.Subject = “Button Version 3.0 Alpha loop=[” & Cstr(c) & “].”

. . . .Call EmailDoc.Send(False,EmailDoc.SendTo(0))

. . . .Set EmailDoc = Nothing . .

. .End If

Subject: RE: How to copy multipart Field (e.g. Rich Text or $File)

Thanks to all the help by Normunds Kalnberzins (in my original thread ==> )

It appears this will work to copy ALL the part of a Large fields that appears multiple times in the Field Property List:

(In this case I just wanted to copy all the “TheButton” values and add them to the Body.

Call EmailBody.AppendText(“vvvv ---- Before ---- vvvv”)

Call EmailBody.AddNewline(2)

Call EmailDoc.Save(False,False)

Set dc = thisDB.search(searchstring, Nothing,0)

If (dc.count = 1) Then

. .Set ButtonDoc = dc.GetNthDocument(1)

. .c=0

. .Forall i In buttonDoc.items

. . . .If Ucase(i.name)=“THEBUTTON” Then

. . . . . .Set itm = buttonDoc.Items(c)

. . . . . .Call EmailDoc.CopyItem(itm,“Body”)

. . . .End If

. . . .c = c + 1

. .End Forall

End If

Call EmailDoc.Save(False,False)

Call EmailBody.AddNewline(2)

Call EmailBody.AppendText(“^^^^ ---- After ---- ^^^^”)

Call EmailDoc.Save(False,False)

EmailDoc.Subject = “Button Version 3.0 Alpha loop=[” & Cstr(c) & “].”

Call EmailDoc.Send(False,EmailDoc.SendTo(0))

Set EmailDoc = Nothing

Without the Save’s before the copyitem to add to the “Body” field the order seems to get messde up and when I try to open the document I get a message about the system Ignoring the portion…

By addnig the Saves things work much better and I ultimate get the results I wanted. Thanks again everyone for the help.