Call doc.Send(False) works for everyone but one user on one machine

I have a time off request db that the supervisor approves a time off for an employee. The code works fine for everyone except for one supervisor and one employee. Her other employees she can approve fine but this one employee it goes down through the code and jumps out of a sub at a certain point (indicated below in the sub)

I have logged on as this supervisor on my machine and it works fine, but on hers it jumps out.

Here is the code:

Options

Option Public

Option Declare

%INCLUDE “LSConst.LSS”

Initialize

Sub Initialize

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim profiledoc As NotesDocument

Dim routingdoc As NotesDocument

Dim dirDB As NotesDatabase

Dim routingDB As NotesDatabase

Dim routingview As NotesView

Dim item As NotesItem

Dim comments As String 

Dim LeaveBalance As Single

Dim LeaveRequested As Single

Dim LeaveUsed As Single

Dim Unpaid As Single

Dim empKey As String

Dim status As String

Dim resp As Integer

Dim server As String

Dim data As NotesDatabase





On Error Resume Next

Set session = New NotesSession

Set data = session.CurrentDatabase

server = data.Server

Set uidoc = ws.CurrentDocument

Set doc = uidoc.Document



 'Initialize access to mail routing database

Set routingDB = session.GetDatabase(server, "EMPrte.nsf")

'Set routingDB = session.GetDatabase("empdev/EMP", "EMPrte.nsf")



If Not (routingDB.IsOpen) Then

	Msgbox "Error: unable to access mail routing database.  Unable to approve leave request at this time.", MB_ICONSTOP, "ERROR"

	Exit Sub

Else

	Set routingview = routingDB.GetView("Intranet Routing")

	If routingview Is Nothing Then

		Msgbox "Error: unable to access a required view in the mail routing database.  Unable to approve leave request at this time.", MB_ICONSTOP, "ERROR"

		Exit Sub

	Else

		Set routingdoc = routingview.GetDocumentByKey("Time Off")

		If routingdoc Is Nothing Then

			Msgbox "Error: unable to access mail routing data.  Unable to approve leave request at this time.", MB_ICONSTOP, "ERROR"

			Exit Sub

		End If

	End If

End If



 'Access the Employee's profile document and subtract from the available leave balance     



Set DirDB = session.GetDatabase(server, "EMPlDir.nsf")     'What should we do about this?

'Set DirDB = session.GetDatabase("empdev/EMP", "EmplDir.nsf")



If Not(DirDB.IsOpen) Then

	Msgbox "Error: unable to access the server copy of the EMP directory.  Unable to approve leave request at this time.", MB_ICONSTOP, "ERROR"

	Exit Sub

Else

	'If DirDb.CurrentAccessLevel = ACLLEVEL_AUTHOR Then

	If DirDb.CurrentAccessLevel < 3 Then

		

		Msgbox "Error: you are not listed as a member of the Supervisor group in the EMP directory.  Unable to approve leave request at this time.", MB_ICONSTOP, "ERROR"

		Exit Sub     

	Else

		empKey = doc.ProfileUNID(0)               

		Set profiledoc = DirDB.GetDocumentbyUNID(empKey)

		If profiledoc Is Nothing Then

			Msgbox "Error: unable to access the employee profile.  Unable to approve leave request at this time.", MB_ICONSTOP, "ERROR"

			Exit Sub

		Else

'start of unpaid

			If doc.VAC_Type(0) = "Unscheduled Unpaid Leave" Or doc.VAC_Type(0) = "CFRA Leave" Or doc.VAC_Type(0) = "Leave of Absence" Or doc.VAC_Type(0) = "Scheduled Unpaid Leave" Or  doc.VAC_Type(0) = "Scheduled Unpaid Days" Or doc.VAC_Type(0) = "Scheduled Unpaid Holiday" Or doc.VAC_Type(0) = "Bereavement" Or doc.VAC_Type(0) = "Jury Duty" Or doc.VAC_Type(0) = "Time Off for Voting" Or doc.VAC_Type(0) = "Conference/Training/Seminar" Or doc.VAC_Type(0) = "Workers Comp - 1st Appt Only"  Or doc.VAC_Type(0) = "Unpaid School Activities" Or doc.VAC_Type(0) = "FMLA (without pay)"  Or doc.VAC_Type(0) = "CFRA Unpaid Leave" Then		

				status = "Noted"					

				doc.VAC_Status = status

				Set item = doc.GetFirstItem("VAC_History")

				Call item.AppendtoTextList(Format$(Now, "mm/dd/yyyy hh:mm:ss AM/PM") + ":  Status changed to " + status + " by " + session.CommonUserName)  

				doc.VAC_CancelReqButton = "Yes"   'enable cancel action button

				

 'Prompt to append comments

				resp = Msgbox("Do you want to append any comments to your approval?", MB_YESNO, "Comments")

				If resp = 6 Then

					comments = Inputbox("Please enter any comments below:", "Add Comments")

					If comments <> "" Then

						Call item.AppendtoTextList(Format$(Now, "mm/dd/yyyy hh:mm:ss AM/PM") + ":  COMMENT - " + comments)

					End If

				End If				

 'Send notice to accounting/payroll dept

				If SendNotices(routingdoc, doc) Then

					Call profiledoc.ComputeWithForm(True,False)

					Call profiledoc.Save(True, False)

					Call doc.Save(True, False)

					Exit Sub

				Else

					Msgbox "Problem with request! Please contact IS.", MB_ICONSTOP, "ERROR"

					Exit Sub						

				End If					

			End If

'end of unpaid

'start of paid

	'////////////////////////////////////////

			

			If	doc.VAC_Type(0) = "Scheduled Paid Leave"  Or doc.VAC_Type(0) =  "Scheduled Paid Leave – Kin Care"  Or doc.VAC_Type(0) = "Scheduled Leave Intro Period" Or doc.VAC_Type(0) = "Scheduled Paid Holiday" Or doc.VAC_Type(0) = "Scheduled Leave Intro Period - Kin Care"  Or doc.VAC_Type(0) = "Paid School Activities" Or doc.VAC_Type(0) = "FMLA (with pay)"  Or doc.VAC_Type(0) = "CFRA Paid Leave" Or doc.VAC_Type(0) = "Unscheduled Non-Penalty" Then

				

				

				LeaveRequested = doc.VAC_Hrs(0)

				LeaveBalance = profiledoc.LeaveBalance(0)

				LeaveUsed = profiledoc.LeaveUsed(0)

				If LeaveBalance < LeaveRequested Then

					Msgbox "Error: this request exceeds the employee's available leave balance.  Unable to approve leave request at this time.", MB_ICONSTOP, "ERROR"

					Exit Sub

				Else

					If doc.VAC_90Days(0) = "True" Then 

						status = "Approved (Pending Expiration of 90 Day Period)"

					Else

						status = "Approved"

					End If

					

					doc.VAC_Status = status

					Set item = doc.GetFirstItem("VAC_History")

					Call item.AppendtoTextList(Format$(Now, "mm/dd/yyyy hh:mm:ss AM/PM") + ":  Status changed to " + status + " by " + session.CommonUserName)  

					doc.VAC_CancelReqButton = "Yes"   'enable cancel action button

					

                             'Prompt to append comments

					resp = Msgbox("Do you want to append any comments to your approval?", MB_YESNO, "Comments")

					If resp = 6 Then

						comments = Inputbox("Please enter any comments below:", "Add Comments")

						If comments <> "" Then

							Call item.AppendtoTextList(Format$(Now, "mm/dd/yyyy hh:mm:ss AM/PM") + ":  COMMENT - " + comments)

						End If

					End If

				End If

                           'Send notice to accounting/payroll dept

				If SendNotices(routingdoc, doc) Then							

					profiledoc.LeaveUsed = LeaveUsed + LeaveRequested

					Call profiledoc.ComputeWithForm(True,False)

					Call profiledoc.Save(True, False)

					Call doc.Save(True, False)

					

				Else

					Msgbox "Problem with request! Please contact IS.", MB_ICONSTOP, "ERROR"

					Exit Sub						

				End If

		'//////////////////////////	

				

			Elseif doc.VAC_Type(0) = "Volunteer Firefighter" Then

				

				LeaveRequested = doc.VAC_Hrs(0)

				LeaveBalance = profiledoc.LeaveBalance(0)

				LeaveUsed = profiledoc.LeaveUsed(0)

				If LeaveBalance < LeaveRequested Then

					Msgbox "Error: this request exceeds the employee's available leave balance.  Unable to approve leave request at this time.", MB_ICONSTOP, "ERROR"

					Exit Sub

				Else

					If doc.VAC_90Days(0) = "True" Then 

						status = "Approved (Pending Expiration of 90 Day Period)"

					Else

						status = "Approved"

					End If

					

					doc.VAC_Status = status

					Set item = doc.GetFirstItem("VAC_History")

					Call item.AppendtoTextList(Format$(Now, "mm/dd/yyyy hh:mm:ss AM/PM") + ":  Status changed to " + status + " by " + session.CommonUserName)  

					doc.VAC_CancelReqButton = "Yes"   'enable cancel action button

					

                              'Prompt to append comments

					resp = Msgbox("Do you want to append any comments to your approval?", MB_YESNO, "Comments")

					If resp = 6 Then

						comments = Inputbox("Please enter any comments below:", "Add Comments")

						If comments <> "" Then

							Call item.AppendtoTextList(Format$(Now, "mm/dd/yyyy hh:mm:ss AM/PM") + ":  COMMENT - " + comments)

						End If

					End If

					

                                 'Send notice to accounting/payroll dept

					If SendNotices(routingdoc, doc) Then							

						profiledoc.LeaveUsed = LeaveUsed + LeaveRequested

						Call profiledoc.ComputeWithForm(True,False)

						Call profiledoc.Save(True, False)

						Call doc.Save(True, False)

					Else

						Msgbox "Problem with request! Please contact IS.", MB_ICONSTOP, "ERROR"

						Exit Sub						

					End If

				End If

			Elseif	doc.VAC_Type(0) = "Paid School Activities" Then

				

				LeaveRequested = doc.VAC_Hrs(0)

				LeaveBalance = profiledoc.LeaveBalance(0)

				LeaveUsed = profiledoc.LeaveUsed(0)

				If LeaveBalance < LeaveRequested Then

					Unpaid = LeaveRequested - LeaveBalance

					Msgbox "Problem: Your request exceeds the employee's available leave balance. You will be paid for " + Cstr(LeaveBalance)+ " and need to submit a Unpaid School Activities request for " + Cstr(Unpaid) + " ." , MB_ICONSTOP, "PROBLEM"

					LeaveRequested  = LeaveBalance

				End If

				If doc.VAC_90Days(0) = "True" Then 

					status = "Approved (Pending Expiration of 90 Day Period)"

				Else

					status = "Approved"

				End If

				

				doc.VAC_Status = status

				Set item = doc.GetFirstItem("VAC_History")

				Call item.AppendtoTextList(Format$(Now, "mm/dd/yyyy hh:mm:ss AM/PM") + ":  Status changed to " + status + " by " + session.CommonUserName)  

				doc.VAC_CancelReqButton = "Yes"   'enable cancel action button

				

         'Prompt to append comments

				resp = Msgbox("Do you want to append any comments to your approval?", MB_YESNO, "Comments")

				If resp = 6 Then

					comments = Inputbox("Please enter any comments below:", "Add Comments")

					If comments <> "" Then

						Call item.AppendtoTextList(Format$(Now, "mm/dd/yyyy hh:mm:ss AM/PM") + ":  COMMENT - " + comments)

					End If

				End If

				

              'Send notice to accounting/payroll dept

				If SendNotices(routingdoc, doc) Then							

					profiledoc.LeaveUsed = LeaveUsed + LeaveRequested

					Call profiledoc.ComputeWithForm(True,False)

					Call profiledoc.Save(True, False)

					Call doc.Save(True, False)

				Else

					Msgbox "Problem with request! Please contact IS.", MB_ICONSTOP, "ERROR"

					Exit Sub						

				End If

			End If 

		End If

	End If 

End If

End Sub

SendNotices:

Function SendNotices(routingdoc As NotesDocument, currentdoc As NotesDocument)

Dim maildoc As NotesDocument

 'Admin Notice     

Dim SendTo As Variant

Dim CC As Variant

Dim richie As NotesRichTextItem	

Dim ln As Variant



Set db = session.CurrentDatabase

ln = currentdoc.LastName(0)



 'Employee Notice

Set maildoc = db.CreateDocument 

maildoc.SendTo = currentdoc.VAC_Employee_Name(0)

maildoc.Subject = "Your request for time off from "+ Cstr(currentdoc.VAC_DateFrom(0)) + " to " + Cstr(currentdoc.VAC_DateTo(0)) + " has been approved"

maildoc.Body = currentdoc.VAC_Supervisor(0) + " has approved the request on " + Cstr(Today)	

Jumps out here—> Call maildoc.Send(False)*****************

	If currentdoc.UserDepartment(0) = "Site Administration"  And Instr(currentdoc.UserTitle(0), "EMP") <> 0 Then

		SendTo= routingdoc.GetItemValue("VAC_Timeclock")

	Elseif currentdoc.UserDepartment(0) = "ESCALLATE, LLC" Then 

		SendTo=routingdoc.GetItemValue("VAC_TimeclockEscallate")		

	Else

		SendTo= routingdoc.GetItemValue("VAC_Timeclock2")

	End If	

	



CC = routingdoc.GetItemValue("VAC_hrEMP")

If currentdoc.VAC_90Days(0) = "True" Then

	Dim bcc As Variant          

	bcc =  routingdoc.GetItemValue("VAC_hrEMP2")

End If



Set maildoc = db.CreateDocument

maildoc.SendTo = SendTo

maildoc.CC = cc

maildoc.bcc = bcc     

maildoc.Subject = "Notification of Time Off for " + currentdoc.FirstName(0) + " " + currentdoc.LastName(0)

Set richie = New NotesRichTextItem(maildoc, "Body")

richie.AppendText ("****PLEASE MAKE THE NECESSARY CHANGES****" + Chr(10) + _   

"Employee Name------------------------------------------" + currentdoc.FirstName(0) + " " + currentdoc.LastName(0)+ Chr(10) + _

"Extension-----------------------------------------------------" + Cstr(currentdoc.VAC_Ext(0)) + Chr(10) + _ 

"Department--------------------------------------------------" + currentdoc.VAC_Department(0) + Chr(10) + _

"Supervisor----------------------------------------------------" + currentdoc.VAC_Supervisor(0) + Chr(10) + _

"Type of Time Off------------------------------------------" + currentdoc.VAC_Type(0) + Chr(10) + _

"Pay Code-----------------------------------------------------" + currentdoc.VAC_CodeGen(0) + Chr(10) + _

"Dates Off-----------------------------------------------------" + Cstr(currentdoc.VAC_DateFrom(0)) + " - " + Cstr(currentdoc.VAC_DateTo(0)) + Chr(10) + _

"Total Hours Off--------------------------------------------" + Cstr(currentdoc.VAC_Hrs(0)) + Chr(10) + Chr(10) +  _

"Comments----------------------------------------------------" + currentdoc.VAC_Comments(0) + Chr(10) + Chr(10))



Call richie.AppendDocLink(currentdoc, "The Request")

Call maildoc.Send(False)     



Dim tmpName As New NotesName(SendTo(0))



If Instr(currentdoc.UserTeam(0) , "Region") = 0 Then

	Msgbox "This leave request data has been forwarded to " + tmpName.Common, MB_ICONINFORMATION, "Time Off Approved"

Else

	Msgbox "This leave request data has been forwarded to the Time Off Request Manager.", MB_ICONINFORMATION, "Time Off Approved"

End If

SendNotices = True

End Function

Subject: Maildoc.Send problem

It is difficult to know what the problem is. Does the program generate an error? I would suggest adding some error checking.

Look for a clashing e-mail address in the local address book. That’s a possibility.

Subject: local address book

Check the supervisors local address book, as mentioned before, and also their recent contacts, in case it is storing an entry for that user name. I think this was supposed to be fixed but we had issues initially with the recent contacts and duplicate names.

A programmatic send will fail to deal with duplicate addresses, I would say this is the most likely cause.