Private Sub cmdApprove_Click()
Me.txtApprovedBy = CurrentUser()
Me.txtApprovalDate = Now()
Dim strEmail, strBody, strCCEmail As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'Creates an Instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
txtDate = Me.txtDate
txtEID = Me.txtID
txtPrinter = Me.cboPrinter
txtEmpID = Me.cboEmpID
txtEmpName = Me.txtEmpName
txtReqNo = Me.txtReqNo
txtTotalClicks = Me.txtTotalClicks
txtJobID = Me.txtJobID
txtJobName = Me.txtJobName
txtPaperStock = Me.cboPaperStock
txtReason = Me.txtReason
txtAppBy = Me.txtApprovedBy
txtAppDate = Me.txtApprovalDate
txtEmail = Me.txtEmail
'Create String with email address
strEmail = "Docutek; " & txtEmail
strBody = txtDate & Chr(13) & Chr(13)
strBody = strBody & "The following discrepancy has been approved." & Chr(13) & Chr(13)
strBody = strBody & "ID: " & txtEID & Chr(13)
strBody = strBody & "Emp. ID: " & txtEmpID & Chr(13)
strBody = strBody & "Employee Name: " & txtEmpName & Chr(13)
strBody = strBody & "Printer: " & txtPrinter & Chr(13)
strBody = strBody & "Req #: " & txtReqNo & Chr(13)
strBody = strBody & "Total Clicks: " & txtTotalClicks & Chr(13)
strBody = strBody & "Job ID: " & txtJobID & Chr(13)
strBody = strBody & "Job Name: " & txtJobName & Chr(13)
strBody = strBody & "Paper Stock: " & txtPaperStock & Chr(13)
strBody = strBody & "Reason: " & txtReason & Chr(13)
strBody = strBody & "Approved By: " & txtAppBy & Chr(13)
strBody = strBody & "Approval Date: " & txtAppDate & Chr(13)
'Creates and sends email
With objEmail
.To = strEmail
.CC = "Vance, William; Marin, Sandra"
.Subject = "Discrepancy Approved"
.Body = strBody
.Send
End With
Set objEmail = Nothing
MsgBox "Discrepancy has been approved.", vbOKOnly + vbInformation, "Discrepancy Approved"
DoCmd.Close acForm, "frmDiscrepancyApp"
Exit Sub
End Sub
|