Using DXL to change links in a loop

DXL novice. Issue with using DXL to change links in a loop.

The program collects documents to be mailed with data regarding the file link information. Per the client specs, there is a master document with an icon and generic file link related to the icon. The program cycles through the collection, pulls the link information, changes it in the model document via DXL, makes a copy of the model document adding the mail information and mails the copy. The process then repeats with the next document in the collection. However, the process dies after the “exporter.Process” statement in the code below. Please advise what can be done to remedy this situation. Thanks.

Sub Initialize

Set session = New NotesSession

Dim db As NotesDatabase

Set db = session.CurrentDatabase

Dim dc As NotesDocumentCollection

Set dc = db.UnprocessedDocuments

Dim doc As NotesDocument

Dim arSend(0) As String



'Pull the model document with the file link tied to an icon

Dim docMask As NotesDocument

Set docMask = db.GetDocumentByUNID("3A983E0F00744976852573230065FFB8")



'Set up DXL connections

Dim exporter As NotesDXLExporter

Set exporter = session.CreateDXLExporter(docMask)

exporter.ExitOnFirstFatalError = False 

Dim parser As NotesDOMParser

Set parser = session.CreateDOMParser(exporter)

On Event PostDOMParse From parser Call ProcessDOM

Dim importer As NotesDXLImporter

Set importer = session.CreateDXLImporter(parser, db)

importer.DocumentImportOption = DXLIMPORTOPTION_REPLACE_ELSE_IGNORE



Dim docMail As NotesDocument



Set doc = dc.GetFirstDocument

Do While Not doc Is Nothing

	strFile = doc.Files2Email(0) 'Get the file name

	arSend(0) = doc.SendTo(0)

	

	exporter.Process



	'Create E-Mail

	Set docMail = docMask.CopyToDatabase(db)

	docMail.Subject = "Test"

	Call docMail.Send(False, arSend)

	

	Set doc = dc.GetNextDocument(doc)

Loop

End Sub

Sub ProcessDOM(Source As NotesDOMParser)

Dim rootElement As NotesDOMElementNode

Set rootElement = Source.Document.DocumentElement

Dim docList As NotesDOMNodeList

Set docList = rootElement.GetElementsByTagName("urllink")

If docList.NumberOfEntries =1 Then 'There is only one link to change

	Dim i As Integer

	For i = 1 To docList.NumberOfEntries

		Dim eNode As NotesDOMElementNode

		Set eNode = docList.GetItem(i)

		strFile = "file:\\" & strFile

		Call eNode.SetAttribute("href", strFile)

	Next i

End If



Source.Serialize

End Sub

Subject: Using DXL to change links in a loop

Check dc.count to see how many docs are in the collection.

Then check the agent properties to see how many docs is it set to run on, as these determine the collection count

a. Documents selected in view

b. New documents

c. New & Modified documents