P
Peter Png
I have a Outlook 2000 leave form that user used to apply
leave. The form is then emailed to the approval and the
approval opened the form to approve or reject. The reply
is then emailed back to applicant.
The Outlook form did not work for the approval. When you
click on the approve button nothing happened. I understand
MAPI doesn't work on Exchange 2000.
Here is the approve subroutine:
Sub cmdApproveLeave_Click()
Set cControls = Item.GetInspector.ModifiedFormPages
("Message").Controls
If cControls("txbDisableFunctions").text = "888" Then
Msg = "ERROR: This Leave application has
already been Approved."
MsgBox Msg, vbOKOnly, "Approval already granted"
End if
If cControls("txbDisableFunctions").text = "777"
Then
Msg = "ERROR: This Leave application has
already been Denied."
MsgBox Msg, vbOKOnly, "Application already
denied"
End if
If cControls("txbDisableFunctions").text = "999"
Then
Set cControls =
Item.GetInspector.ModifiedFormPages ("Message").Controls
Set objApproval = Application.CreateItem(0)
objApproval.To = Item.SenderName
If cControls("txbDateFrom") = cControls
("txbDateTo") Then
objApproval.Subject = "Application for
Leave - APPROVED - " & cControls("txbName") & _
" - " & cControls("txbDateTo") & " - Day
only"
Else
objApproval.Subject = "Application for
Leave - APPROVED - " & cControls("txbName") & _
" - " & cControls("txbDateFrom") & " to "
& cControls("txbDateTo")
End if
objApproval.Body = _
"Your Manager has approved " & _
"your request for leave between the dates
of: " & vbCr & _
cControls("txbDateFrom").text & " and " & _
cControls("txbDateTo").text & vbCr & vbCr & _
"LEAVE DETAILS ARE AS FOLLOWS:" & vbCr &
vbCr & _
"Employee Name: " &
cControls("txbName").text & vbCr & vbCr & _
"Shift: " &
cControls("cmbShift").text & vbCr & vbCr & _
"Type of Leave : " &
cControls("cmbLeaveType").text & vbCr & vbCr & _
"Reason for Leave: " &
cControls("txbReasonLeave").text & vbCr & vbCr & _
"Period of leave (Inclcusive): " &
cControls("txbDateFrom").text & " to the " & _
cControls("txbDateTo").text & vbCr & vbCr
& _
"Date Returning to Work: " &
cControls("txbDateReturn").text & vbCr & vbCr & _
"Number of Working days on Leave: " &
cControls("txtNumberDays").text
objApproval.Send
cControls("txbDisableFunctions").text = "888"
Set myNameSpace = Application.GetNameSpace("MAPI")
Set myForward = Item.Forward
myForward.Recipients.Add HumanResources
If cControls("txbDateFrom") = cControls
("txbDateTo") Then
myForward.Subject = "Application for
Leave - APPROVED - " & cControls("txbName") & _
" - " & cControls("txbDateTo") & " - Day
only"
Else
myForward.Subject = "Application for
Leave - APPROVED - " & cControls("txbName") & _
" - " & cControls("txbDateFrom") & " to "
& cControls("txbDateTo")
End if
myForward.Send
Msg = "Outlook has sent a notice to " _
& Item.SenderName & " approving the request."
& _
vbCr & "Details have also been forwarded to HR"
MsgBox Msg, vbOKOnly, "Request: Approval
Sent"
End if
Item.save
Item.Close 1
End Sub
leave. The form is then emailed to the approval and the
approval opened the form to approve or reject. The reply
is then emailed back to applicant.
The Outlook form did not work for the approval. When you
click on the approve button nothing happened. I understand
MAPI doesn't work on Exchange 2000.
Here is the approve subroutine:
Sub cmdApproveLeave_Click()
Set cControls = Item.GetInspector.ModifiedFormPages
("Message").Controls
If cControls("txbDisableFunctions").text = "888" Then
Msg = "ERROR: This Leave application has
already been Approved."
MsgBox Msg, vbOKOnly, "Approval already granted"
End if
If cControls("txbDisableFunctions").text = "777"
Then
Msg = "ERROR: This Leave application has
already been Denied."
MsgBox Msg, vbOKOnly, "Application already
denied"
End if
If cControls("txbDisableFunctions").text = "999"
Then
Set cControls =
Item.GetInspector.ModifiedFormPages ("Message").Controls
Set objApproval = Application.CreateItem(0)
objApproval.To = Item.SenderName
If cControls("txbDateFrom") = cControls
("txbDateTo") Then
objApproval.Subject = "Application for
Leave - APPROVED - " & cControls("txbName") & _
" - " & cControls("txbDateTo") & " - Day
only"
Else
objApproval.Subject = "Application for
Leave - APPROVED - " & cControls("txbName") & _
" - " & cControls("txbDateFrom") & " to "
& cControls("txbDateTo")
End if
objApproval.Body = _
"Your Manager has approved " & _
"your request for leave between the dates
of: " & vbCr & _
cControls("txbDateFrom").text & " and " & _
cControls("txbDateTo").text & vbCr & vbCr & _
"LEAVE DETAILS ARE AS FOLLOWS:" & vbCr &
vbCr & _
"Employee Name: " &
cControls("txbName").text & vbCr & vbCr & _
"Shift: " &
cControls("cmbShift").text & vbCr & vbCr & _
"Type of Leave : " &
cControls("cmbLeaveType").text & vbCr & vbCr & _
"Reason for Leave: " &
cControls("txbReasonLeave").text & vbCr & vbCr & _
"Period of leave (Inclcusive): " &
cControls("txbDateFrom").text & " to the " & _
cControls("txbDateTo").text & vbCr & vbCr
& _
"Date Returning to Work: " &
cControls("txbDateReturn").text & vbCr & vbCr & _
"Number of Working days on Leave: " &
cControls("txtNumberDays").text
objApproval.Send
cControls("txbDisableFunctions").text = "888"
Set myNameSpace = Application.GetNameSpace("MAPI")
Set myForward = Item.Forward
myForward.Recipients.Add HumanResources
If cControls("txbDateFrom") = cControls
("txbDateTo") Then
myForward.Subject = "Application for
Leave - APPROVED - " & cControls("txbName") & _
" - " & cControls("txbDateTo") & " - Day
only"
Else
myForward.Subject = "Application for
Leave - APPROVED - " & cControls("txbName") & _
" - " & cControls("txbDateFrom") & " to "
& cControls("txbDateTo")
End if
myForward.Send
Msg = "Outlook has sent a notice to " _
& Item.SenderName & " approving the request."
& _
vbCr & "Details have also been forwarded to HR"
MsgBox Msg, vbOKOnly, "Request: Approval
Sent"
End if
Item.save
Item.Close 1
End Sub