NotesDXLImporter and adding attachment

Hello,

I have an agent who create Document from XML file.

The process works fine.

But I want add an attachment in the body of my document. I don’t know how to do because I never do a doc.save

What is the best solution :

  • to add the attachment before to do import.process ?

  • or retrieve the UNID and update my document ?

Thanks to give me the best way and how to do it.

Nicolas

Please see below my agent :


Sub ImportXML(XmlFileName As String, serverName As String, dabaseName As String)

Dim session As New NotesSession

Dim db2 As NotesDatabase



Print "serverxml : " & "" & serverName & ""

Print "dabaseNamexml : " & "" & dabaseName & ""



Set db2 = New NotesDatabase(serverName,  dabaseName)



Dim stream As NotesStream

Set stream = session.CreateStream



If Not stream.Open("./temp/" & XmlFileName) Then

	Print "WARNING : Cannot open " & XmlFileName

	Exit Sub

End If

If stream.Bytes = 0 Then

	Print "WARNING : File " & XmlFileName & " did not exist or was empty"

	Exit Sub

End If



Dim importer As NotesDXLImporter

Set importer = session.CreateDXLImporter(stream, db2)

Call importer.Process

End Sub

Subject: Use

This is perhaps a little-known and not-well-enough-advertised feature of DXL. When you export attachments, you always currently get the attachment’s data as the Base64 content within a separate element. But for purposes of importing, you can specify within richtext and it will import the filespec from the system and make an attachment of it, without a separate $FILE item being part of the import.

Subject: NotesDXLImporter and adding attachment

The easiest way is probably going to be the second way: open the created document and update it.

If the attachment is not too big, you can in-line it in the XML in base64 encoding. My guess is that this approach isn’t to good for performance (more memory required during parsing + extra encoding/decoding cycle).

cheers,

Bram

Subject: RE: NotesDXLImporter and adding attachment

Ok,but how to retrieve the UNID after a importer.process in a DXL process ?

Subject: RE: NotesDXLImporter and adding attachment

There are native nethods: NotesDXLImporter.GetFirstImportedNoteID/GetNextImportedNotedID