Не работает агент по расписанию


Well-known member
Добрый день!
Есть агент, который отправляет файлы по адресу из папки. Так вот по расписанию он упорно работать не хочет,а когда руками запускаешь,то работает. Не подскажите в чем причина?
В логе пишется ошибка AMgr: Agent ('Send Mail' in 'mail\***.nsf') error message: Notes error: Unable to find path to server. To trace this connection, use File - Preferences - User Preferences - Ports - Trace (Notes client) or Trace. Это выводит при команде Call dbdoc.Send( False)
Трассировку я делал.
Вот код агента

Const ASCIIDir = "\\LOTUS\OSV"

Sub Initialize
Dim session As New Notessession
Dim db As Notesdatabase
Dim sendfile As String
Set db = session.Currentdatabase
Print "Агент: ЙА - агентег автоматической отправки почты"
Print "Сервер: Пеши исчо!"
' Look for any file in the default ASCII directory, dir$ returns one file at a time from the string given it
Dim pathName As String, fileName As String
pathName = ASCIIDir & "\sendready.txt"
fileName = Dir$(pathName, 0)
' Process all files in pathName$)
Do While fileName <> ""
sendfile = ASCIIDir & "\" & filename
Call ProcessFile(sendfile, session, db)
fileName = Dir()
End Sub

Function ProcessFile (sendfile As String, session As Notessession, db As Notesdatabase) As Integer
' ready a notes memo, the body field is a richtext type.
Dim dbdoc As Notesdocument
Dim body As Notesrichtextitem
Set dbdoc = New NotesDocument( db )
dbdoc.Form = "Memo"
' open ascii file and read every line
fileNum% = Freefile()
Open sendfile For Input As fileNum%
Do While Not Eof(fileNum%)
' Read each line of the file.
Line Input # fileNum%, txt$
' Find delimiter position, I have chosen ":" as the delimiter
delpos = Instr (txt$ , ":" )
' The action "verb" is on the left and the text on the right of the delimiter
action = Ucase(Trim(Left(txt$, delpos - 1)))
clause = Trim(Mid(txt$, delpos + 1, Len(txt$) - delpos))
' You could add any actions here you need.
Select Case action
Case "TO"
dbdoc.SendTo = clause
Case "CC"
dbdoc.CopyTo = clause
Case "BCC"
dbdoc.BlindCopyTo = clause
dbdoc.Subject = clause
Case "BODY"
Set body = New NotesRichTextItem( dbdoc, "Body" )
Call body.AppendText(clause & Chr(10))
Set body = New NotesRichTextItem( dbdoc, "Body")
Call Body.EmbedObject(EMBED_ATTACHMENT, "", clause)
Kill clause
Case Else
End Select
' Check for missing SendTo, you could log these errors to a text file, I'm just making them show up on the screen
If Not (dbdoc.HasItem("SendTo")) Then
Print ("No send to found for this text file")
Exit Function
End If
' Send document
dbdoc.PostedDate = Now
' This sets the field to save the message
dbdoc.SaveMessageOnSend = True
Print "do otpravki"
Call dbdoc.Send( False)
Print "posle otpravki"
' Delete ASCII file
Close fileNum%
Kill sendfile
End Function

содержимое sendready.txt