Hi @ALL,
mal wieder ein kleines Problem. Habe einen Agenten geschrieben, der Attachments aus einer Mail auf einen bestimmten Share lösen soll, danach wird eine auf dem Share befindliche exe-Datei angestartet, die den ZIP entpackt, auf Validatät überprüft und die entpackten Dateien in einen anderen Share schiebt.
Lokal funktioniert der Agent einwandfrei. Nur nicht auf dem Server ! Konsolenmeldung Server: object variable not set... ich arbeite auf einem Server, auf dem ich komplette Execution Rechte für die Skripte habe
On Error Goto ErrorHandler
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim view As NotesView
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim rtitem As Variant
Dim object As NotesEmbeddedObject
Dim fileCount As Integer
Dim tempshare, mailinshare As String
Dim message As String
Dim mail As NotesDocument
Dim stream As NotesStream
'### DEFINE Sharefolders
tempshare = "\\server1\mailin$\TEMP\"
mailinshare = "\\server1\mailin$\Anonymous\"
Set db = session.CurrentDatabase
Set view = db.GetView("($Inbox)")
fileCount = 0
Set doc = view.GetFirstDocument
While Not(doc Is Nothing)
Set rtitem = doc.GetFirstItem( "Body" )
'### Check: Attachment available ?
If doc.HasEmbedded = True Then 'Loop 1
If ( rtitem.Type = RICHTEXT ) Then 'Loop 2
'### Here we go ...
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then 'Loop 3
fileCount = fileCount + 1
'# Extract to temporary Directory
Print o.Name
Call o.ExtractFile ( tempshare & o.Name )
'### Start Extraction of files and check
Dim result As Integer
result = Shell(tempshare & "zipchecka.exe " & o.Name, 1)
pathname = tempshare & "validation-" & Left$(o.Name,Len(o.Name)-4) & ".txt"
Sleep 20
Call o.Remove
Call doc.Save( True, True )
'Move processed document to processedfolder
'Call doc.Remove(True)
End If 'End Loop 3
End Forall
Else 'Else Loop 2
Print "No attachments in Document"
doc.subject = doc.subject(0) + "No attachments in document"
Call doc.Save( True, True )
'Move processed document to processedfolder
'Call doc.Remove(True)
Goto NextDoc
End If 'End Loop 2
'Mail generieren mit Informationen
'Sleep 10
Set stream = session.CreateStream
'Stream defined in Loop for detaching files !
'pathname = tempshare & "\validation-" & o.Name & ".txt"
If Not stream.Open(pathname, "ASCII") Then
Messagebox pathname ,, "Open failed"
Exit Sub
End If
If stream.Bytes = 0 Then
Messagebox pathname,, "File has no content"
Exit Sub
End If
'Send mail with information of stream to sender of the mail
Set mail = New NotesDocument(db)
Call mail.ReplaceItemValue("Form", "Memo")
Call mail.ReplaceItemValue("Subject", "Notes2XXX - Information Mail")
mail.sendto = doc.Principal(0)
Call mail.ReplaceItemValue("Body", stream.ReadText())
Call stream.Close
Delete stream
Call mail.Send(False)
pathname =""
Delete mail
End If
NextDoc:
'Call doc.Remove(False)
Set doc = view.GetNextDocument(doc)
Wend
'### Cleanup Documents
ErrorHandler:
routine$ = "Check Attachment Agent - Notes2XXX"
mailError routine$, Err, Erl, Error
Exit Sub