Scheduled agent won't email

I have an agent which works perfectly and emails out when run it manually but will not send an email when scheduled. I have searched the forum and have checked the following:The server does have access to itself and rights to run an agent

The db is signed by the server

There is a default view in the database

The code is this

Sub Initialize

Dim s As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument 

Dim object As NotesEmbeddedObject

Dim rtitem As NotesRichTextItem



Set db = s.CurrentDatabase 

Set doc = New NotesDocument( db )

Set rtitem = New NotesRichTextItem( doc , "Body" )



Dim whenNow As String

whenNow$ = Now()



Dim recipients( 1 To 2 ) As String

recipients( 1 ) = "xxxx"

recipients(2) = "xxxx"



Set object =  rtitem.EmbedObject(EMBED_ATTACHMENT, "", "\\servername\c$\ITPurchCons.csv" )



If rtitem.Type = RICHTEXT Then

	Call rtitem.AddNewLine( 1)

	Call rtitem.AppendText( "DISCLAIMER." )

	

End If

doc.Form = "Memo"

doc.SendTo = recipients

doc.Subject = "Updated Schedule " 





doc.PostedDate = Now

Call doc.Send( False ) 

End Sub

Can anyone tell me what I am missing? TIA

Subject: Scheduled agent won’t email

how about a default form?

Subject: RE: Scheduled agent won’t email

Yes I have one of those. Thanks.

Subject: Scheduled agent won’t email

Are you seeing an error in the server console when this agent runs? I bet you are. I’d also put money on you finding that error in this forum if you search.

Subject: RE: Scheduled agent won’t email

It does throw up an error about not being able to find the csv file but why doesnt that stop it emailing when I run it manually?

Subject: RE: Scheduled agent won’t email

Samantha,

Not the error I was expecting, but then again, I didn’t read your code thoroughly.

When running scheduled, the agent acts as the windows user the service runs as (default is the localsystem account for the server)

so, the UNC path you are using may not be accessible to that account. if that path is local to the server, try using C:\

for ease of testing, you can look at NotesSession.isonserver and conditionally use C:\ or \server\c$\ for the begining of the path

Subject: RE: Scheduled agent won’t email

That was it. The account did not have access to the other server. Thanks very much for your help.