Stampa
Categoria: Lotus Notes
Visite: 6499
Stella inattivaStella inattivaStella inattivaStella inattivaStella inattiva
 

This code can save and optionally remove the attached file (embedded and not as richtext)  for the selected document.

 

Create an agent and insert the following code

Sub Initialize
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim collection As NotesDocumentCollection
	Dim doc As NotesDocument
	Set db = session.CurrentDatabase
	Set collection = db.UnprocessedDocuments
	Set doc = collection.GetFirstDocument()
	While Not(doc Is Nothing)
		Call detachfile(doc)		
		' read next doc - the 1st one was read before the loop
		Set doc = collection.GetNextDocument(doc)		
	Wend	
End Sub

Sub detachfile(doc)
	Dim object As NotesEmbeddedObject
	Set object = doc.GetAttachment( "position.xml" )
	If ( object Is Nothing ) Then  
	Print "UN_Successfull  : " & doc.subject(0)   	 
	Else
		dim filename As String
		Dim a As String
		Dim b As String				
		Print "Successfull  : " & doc.subject(0)
		filename=doc.subject(0)
		a=":"
		b="_"		
		filename= "c:\temp\" & Replace(filename, a, b)
		
		Call object.ExtractFile ( filename & ".xml")
		' Call object.Remove  
		' Call doc.save(True,True)		
	  End If
End Sub

 

- have fun -

DISQUS - Leave your comments here