Tja... wenn man ein wenig in der Knowledgebase suchen würde, dann käme man ruckzuck zum Ergebnis... Schade, dass es immer wieder Programmierer gibt, die Ihre wichtigsten Quellen nicht kennen...
Artikel aus der KB (1104835):
Problem
Some attachments display at the bottom of a document rather than within a Rich Text field. This type of attachment is attached to the document itself and is called a V2-style attachment (because Notes release 2.x could attach files only in this manner). These types of attachments are also created when you attach a file from a Web browser, using a file upload control.
How can you convert a V2-style attachment to an attachment that appears within a Rich Text field?
Solution
This conversion is possible using Notes 4.5.2 and later releases.
The NotesDocument class has an array of NotesItems within its Items property. The Items property itself refers to an array of NotesItems, and the elements within this array have a Values property. It is this Values property that contains the name of the attachment, allowing you to extract the file to disk and then embed the file within a Rich Text field.
The example below demonstrates one method of using these properties and methods to extract an embedded file and then embed it within a Rich Text field. In this example, the Rich Text field name is "RTF". The code sample below does not perform any deletion of the files it writes to disk.
Code Sample:
Sub Initialize
Dim doc As NotesDocument
Dim item As Variant
Dim nitem As Variant
Dim rtitem As Variant
Dim uidoc As notesuidocument
Dim w As New notesuiworkspace
Set uidoc=w.currentdocument
Set doc = uidoc.document
Forall i In doc.Items
If i.type = Attachment Then
Set emb = doc.GetAttachment(i.values(0))
Set rtitem=doc.getfirstitem("RTF")
Call emb.extractfile("C:\" & emb.name)
Call rtitem.embedobject(EMBED_Attachment, "", "C:\" & emb.name, emb.name)
Kill "C:\" & emb.name
Call emb.remove
Call doc.save(1,1)
' If one is only searching for one attachment then remove the remark from the line below
' Exit Forall
End If
End Forall
End Sub
In order to perform these type of file manipulations in background agents, the signer of the agent must be included in the "Run Unrestricted Lotus Script agents" in the Agent Manager section of the Server document in the Name and Address Book.
Related Documents:
Files Attached Using EmbedObject Method Appear as V2 Style Attachments
Document #: 1089682
File Upload Control Places an Attachment in Each Rich Text Field When Using Java Applet
Document #: 1099645
P.S.: Ich habe den folgenden Code mal verwendet, um ein Per File-Upload-Control hinzugefügtes Attachment per WebQuerySaveAgent ins Body- Feld zu kopieren:
Dim ses As New NotesSession
Dim doc As NotesDocument
Dim v2File As NotesItem
Dim rtItem As NotesRichTextItem
Dim inputAttachment As NotesEmbeddedObject
Dim tempDirectory As String
Dim fileName As String
Dim filePath As String
Dim moveToFieldName As String
moveToFieldName = "Rt_Dokument_Anhänge"
Set doc = ses.DocumentContext
Set v2File = doc.GetFirstItem ( "$File" )
fileName = v2File.Values(0)
Set inputAttachment = doc.GetAttachment ( fileName )
tempDirectory = ses.GetEnvironmentString ( "Directory", True )
filePath = tempDirectory + "\" + fileName
'--Save the file on the server
Call inputAttachment.ExtractFile ( filePath )
'--Delete the original attachment
Call doc.RemoveItem ( "$File" )
'--Create the rich text item and re-attach the file
If doc.HasItem ( moveToFieldName ) Then
Set rtItem = doc.GetFirstItem ( moveToFieldName )
Else
Set rtItem = New NotesRichTextItem ( doc, moveToFieldName )
End If
Set inputAttachment = rtItem.EmbedObject ( EMBED_ATTACHMENT, "", FilePath )
'--Finally, delete the file from the server file system
Kill FilePath