Hello
I have used the below code for over 6 months with no problem. Then, one day I come in and I get the error message “The system cannot find the file specified”. I changed nothing so this really confuses me.
To explain a little more, I coded an Access database that makes sure people entered their time to issues. If they did not enter their time, I send an e-mail through my Lotus Notes e-mail (but it is not open when this process runs).
What I do is have the Access database as a scheduled task, I lock my PC but nothing is open. Then at 10:00, the scheduled task runs. This worked perfect for over 6 months, but now it does not.
Does anyone know why I am getting the message? The line of code it is occurring on is:
Call session.Initialize(LotusPassword)
Another weird thing is that if I have notes open, this process works just fine.
Any help would be greatly appreciated.
Thanks
Darren
Here is my code:
Private Sub EmailUserDaily(SendTo As String, AssociateFirstName As String, LotusPassword As String, ServerName As String, MailFile As String, SupEmail As String)
Dim session As NotesSession
Dim MailDb As NotesDatabase
Dim MailDoc As NotesDocument
Dim rtBody As NotesRichTextItem
Dim strBeginMessage As String
Dim strEndMessage As String
'Purpose: Start a session to notes
Set session = CreateObject("Lotus.NotesSession")
Call session.Initialize(LotusPassword)
'Purpose: Open the mail database in Lotus Notes
Set MailDb = session.GetDatabase(ServerName, MailFile)
If MailDb.IsOpen = True Then
'Already open for mail
Else
Call MailDb.Open
End If
'Purpose: Set up the new mail document
Set MailDoc = MailDb.CreateDocument
'Purpose: Set fields in Lotus Notes
Call MailDoc.ReplaceItemValue("SendTo", SendTo)
Call MailDoc.ReplaceItemValue("BlindCopyTo", E-mail Address)
Call MailDoc.ReplaceItemValue("Subject", "Time Tracking Notification for " & runDate)
'Purpose: Populates the supervisor e-mail if it is needed
If SupEmail = " " Or IsNull(SupEmail) Then
'Don't E-Mail Supervisor
Else
Call MailDoc.ReplaceItemValue("CopyTo", SupEmail)
End If
'Purpose: Start the body message
Set rtBody = MailDoc.CreateRichTextItem("Body")
strBeginMessage = "As of " & Date & " at " & Time & " the Client Services Database has detected an insufficient amount of time entered into the database for " & runDate & "."
strEndMessage = "Please make sure you have at least entered " & reqDailyHours & " hours as soon as possible."
rtBody.AppendText (AssociateFirstName)
rtBody.AddNewLine (2)
rtBody.AppendText (strBeginMessage)
rtBody.AddNewLine (2)
rtBody.AppendText (strEndMessage)
rtBody.AddNewLine (2)
rtBody.AppendText ("Thanks!")
rtBody.AddNewLine (1)
rtBody.AppendText ("Client Services Database")
'Purpose: Makes a copy of the e-mail in the Sent folder
MailDoc.SaveMessageOnSend = True
'Purpose: False means no attachment
Call MailDoc.Send(False)
'Purpose: Clean up
Set MailDb = Nothing
Set MailDoc = Nothing
Set session = Nothing
End Sub