Lotus Script: esportare la lista degli allegati presenti in una vista in un file di testo

Questa piccola sub scorre tutti gli elementi di una vista, e ogni volta che trova un documento con un allegato fa queste due cose:

  • In più estrae tutti gli allegati.
  • inserisce una nuova riga in un file di testo, con le informazioni UniversalID, nome del file allegato ed il percorso di dove viene estratto, separate da un “;”.

Accetta in ingresso: il nome del database, il nome della vista, il percorso dove vengono estratti gli allegati, ed il nome del file di testo da andare a scrivere.

Sub esporta(strDatabase as String, view as NotesView, strPercorso as String, strNomeFile as String)Dim sessione As NotesSession

Dim db As NotesDatabase
Dim doc As NotesDocument
Dim view As NotesView
Dim rtitem As NotesRichTextItem
Dim dbSorgente As NotesDatabase
Dim fileNum As Integer

Set sessione = New NotesSession
Set dbSorgente = sessione.GetDatabase("", strDatabase)
Set view = dbSorgente.GetView( view )

fileNum% = Freefile()
Open strNomeFile For Append As fileNum%

Set doc = view.GetFirstDocument
While Not doc Is Nothing

Set rtitem = doc.getfirstitem("body")
Forall o In rtitem.EmbeddedObjects

If ( o.Type = EMBED_ATTACHMENT ) Then

Call o.ExtractFile( strPercorso & o.Source )
Print #fileNum%, doc.UniversalID & ";" & o.Source & ";" & strPercorso

End If

End Forall
Set doc = view.GetNextDocument(doc)

Wend

Close fileNum%

Messagebox("Esportazione terminata con successo")

Exit Sub

ProcessError:

Messagebox("Errore, impossibile generare il file")

End Sub

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>