Private Sub cmdEmail_Click()
Dim strpath As Variant
Dim DocName As String
Dim strSubject As String
Dim strSuffix As String
On Error GoTo ErrProc:
If IsNull(Me.txtPicklistID) Then
MsgBox "Please create a picklist before sending an email.", vbOKOnly + vbCritical
Exit Sub
End If
If Me.Dirty Then
DoCmd.RunCommand acCmdSaveRecord
End If
If Me.sfrmIssueProducts.Form!txtCtnCnt = 1 Then
strSuffix = "Box"
Else
strSuffix = "Boxes"
End If
strSubject = "PickList # " & Me.txtPeachtreePackingSlip & " " & Me.Customer & " " & Me.sfrmIssueProducts.Form!txtCtnCnt & strSuffix
strpath = DLookup("PDFPath", "tblDefaults", "DefaultsID = 1")
DocName = "Picklist-" & Me.txtPeachtreePackingSlip & "_" & Me.Customer & "_" & Me.sfrmIssueProducts.Form!txtCtnCnt & strSuffix
DocName = strpath & DocName & ".pdf"
Kill DocName 'delete existing file if any so outputto won't hang
DoCmd.OutputTo acOutputReport, "rptPicklist", acFormatPDF, DocName
Call Email_Via_Outlook("", strSubject, "", True, DocName)
ExitProc:
Exit Sub
ErrProc:
Select Case Err.Number
Case 53 'file not found
Resume Next
Case Else
MsgBox Err.Number & "--" & Err.Description
Resume ExitProc
Resume Next
End Select
End Sub