here comes the sun ... ähh...code:
Sub Initialize
Const SuchSubject="Bestellung Normen per Autorequest"
Const FolderBearbeiten="AutoAnforderung"
Const FolderErledigt="AutoAnforderung\Erledigt"
Dim dateTime As New NotesDateTime( "01/01/90" ) 'notwendig für selection-Methode
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim doc3 As NotesDocument
Dim reply As NotesDocument
Dim item As NotesItem
Dim uidoc As notesuidocument
Set db = session.CurrentDatabase
Set doc3 = db.CreateDocument
Set uidoc=workspace.currentdocument
Set View = db.GetView( FolderBearbeiten)
Set doc = view.GetFirstDocument
'If doc.HasItem("Subject") Then
While Not(doc Is Nothing)
titel=doc.subject(0)
If titel<>SuchSubject Then Exit Sub
wer$=doc.from(0)
MyBody=doc.body
wo=Instr(1,MyBody,":")
Dok1$=Left(MyBody,wo-1)
Dok2$=Right(MyBody,Len(MyBody)-wo)
Dim db2 As New NotesDatabase( "", "" )
' If Not db2.OpenByReplicaID( "LN02", "41256C2300376F24" ) Then
If Not db2.OpenByReplicaID( "", "C1256CF3004BC5C4" ) Then
Messagebox "Datenbank Normen auf LN02 konnte nicht geöffnet werden!"
Exit Sub
End If
Print "Agent 'DokumentAnfrageNorm': Angeforderte Normen "& Dok1$ & Dok2$ & " werden gesucht"
searchFormula$ = "SELECT @Contains(Dokumentnummer;" & """" & Dok1$ & """" & ") & " & " Dokumentnummer_1 = " &"""" & Dok2$ & """"
Set collection2 = db2.Search( searchFormula$, dateTime, 0 )
Anzahl=collection2.Count
Dim Doc2 As NotesDocument
Set doc2 = collection2.GetNthDocument( 1 )
Call doc2.CopyAllItems( doc3, True )
Call doc3.ReplaceItemValue( "SendTo", wer$)
Call doc3.Send( True )
Print "Agent 'DokumentAnfrageNorm': Angefordete Normen versandt."
Call doc.PutInFolder(FolderErledigt)
Call doc.RemoveFromFolder( FolderBearbeiten)
Print "Agent 'DokumentAnfrageNorm': Dokument nach " & FolderErledigt & " verschoben."
Set doc = view.GetNextDocument(doc)
Wend
'End If
End Sub