Domino 9 und frühere Versionen > ND7: Entwicklung
Agent zum auslagern von Attachmants ins Filsystem
sylli1908:
Hallo Notes - Könner,
ich bastle einen Agenten der nicht will wie er soll.
Er soll Bilder, die als Anhang an den Dokumenten hängen ins Filesystem speichern und aus der Datenbank löschen, da die Datenbank zu gross geworden ist. Anhang heisst das RTF in dem der Anhang steckt. Nach C:\ soll das ganze verschoben werden falls es ein jpg ist.
so sieht das ganze aus:
Sub Initialize
Dim Pfad As String
Dim doc As NotesDocument
Dim obj As NotesEmbeddedObject
Dim rtitem As Variant
Pfad = "C:\"
Set rtitem = doc.GetFirstItem( "Anhang" )
Forall o In rtitem.EmbeddedObjects
If (o.Type = EMBED_ATTACHMENT) Then
If Ucase(Right(o.Source, 4)) = Ucase(".jpg") Then
Call o.ExtractFile(Pfad & o.Source)
End If
End If
End Forall
End Sub
Der Debugger sagt immer: "Object Variable not set? an der
Stelle mit dem Forall.
Wäre für eure Hilfe dankbar. Sylli
flaite:
Das Dokument besitzt kein Item mit dem Namen "Anhang".
Im übrigen musst du rtItem schon als NotesRichTextItem und nicht als Variant deklarieren.
sylli1908:
habe ich geändert. Sieht jetzt so aus:
Sub Initialize
Dim Pfad As String
Pfad = "C:\"
Dim doc As NotesDocument
Dim obj As NotesEmbeddedObject
Dim rtitem As NotesRichTextItem
Set rtitem = doc.GetFirstItem( "Body" )
Forall o In rtitem.EmbeddedObjects
If (o.Type = EMBED_ATTACHMENT) Then ' ist Dateianhang?
If Ucase(Right(o.Source, 4)) = Ucase(".jpg") Then ' ist Dateiendung jpg?
Call o.ExtractFile(Pfad & o.Source) ' abhängen
End If
End If
End Forall
End Sub
Fehlermeldung ist aber die gleiche. Mist.
klaussal:
Doc ist nicht gesetzt.
klaussal:
--- Code: ---Sub Initialize
Dim Pfad As String
Pfad = "C:\"
Dim doc As NotesDocument
Dim obj As NotesEmbeddedObject
Dim rtitem As NotesRichTextItem
Dim collection As NotesDocumentCollection
Dim db As NotesDatabase
Dim session As New NotesSession
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing)
Set rtitem = doc.GetFirstItem( "Body" )
Forall o In rtitem.EmbeddedObjects
If (o.Type = EMBED_ATTACHMENT) Then ' ist Dateianhang?
If Ucase(Right(o.Source, 4)) = Ucase(".jpg") Then ' ist Dateiendung jpg?
Call o.ExtractFile(Pfad & o.Source) ' abhängen
End If
End If
End Forall
Set doc = collection.GetNextDocument(doc)
Wend
End Sub
--- Ende Code ---
Navigation
[0] Themen-Index
[#] Nächste Seite
Zur normalen Ansicht wechseln