Private Sub cmdSend(recipient As String)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim txt As String
Dim varResponse As Variant
On Error GoTo Err_cmdSend
If IsNothing(Forms!frmOrderMan!frmOrderLog.Form!fldJLNote) Then
varResponse = MsgBox("No text found. Would you like to add message?", vbYesNo, gtstrAppTitle)
If varResponse = vbYes Then
Exit Sub
End If
End If
txt = Nz(Forms!frmOrderMan!frmOrderLog.Form!fldJLNote, "")
DoCmd.Hourglass True
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim varWhere As Variant
Dim Subjectline As String
Dim strDearName As Variant
Dim signature As String
Dim mail1 As Variant
Dim mail2 As Variant
Dim strBody As String
Dim strClient As String
Dim strTSEmail As Variant
Dim strCompany As Variant
Dim strCompPhone As String
Dim strCompEmail As String
Dim strCompPhone1 As String
Dim strCompEmail1 As String
Dim strCompPhone2 As String
Dim strCompEmail2 As String
Dim rsemail As DAO.Recordset
Dim Ns As Outlook.NameSpace
Dim Folder As Outlook.MAPIFolder
Dim mySQL As String
Dim varDblGlzRef As Variant
Dim strDescription As String
Dim varX As Variant
varX = Forms!frmlogin!cmbstaff
If Not IsFormLoaded("frmOrderMan") Then Exit Sub
DoCmd.SetWarnings False
Set MyOutlook = New Outlook.Application
Set MyOutlook = CreateObject("Outlook.Application")
Set Ns = MyOutlook.GetNamespace("MAPI")
Set Folder = Ns.GetDefaultFolder(olFolderInbox)
MyOutlook.Explorers.Add Folder
strTSEmail = ""
mail1 = ""
strDearName = ""
If Trim(Forms!frmOrderMan!fldDblGlzSysRef & "") = "" Then
varDblGlzRef = "No ref"
Else
varDblGlzRef = Nz(Forms!frmOrderMan!fldDblGlzSysRef)
End If
mail1 = recipient
'Debug.Print recipient
strClient = ""
Subjectline = "JOB LOG: [" & Nz(Forms!frmOrderMan!fldOrderID) & "] " & varDblGlzRef & " - " & Nz(Forms!frmOrderMan!fldOClientID.Column(1)) & " - " & Nz(Forms!frmOrderMan!fldOAddressID.Column(1)) & " - " & Nz(Forms!frmOrderMan!fldOJobDescription)
''debug.Print Subjectline
strBody = txt
Set MyMail = MyOutlook.CreateItem(olMailItem)
MyMail.Recipients.Add mail1
MyMail.Subject = Subjectline
MyMail.Body = strBody
If varX = 14 Or IsNothing(varX) Then
MyMail.Display
Else
MyMail.Send
End If
'SendKeys "^{END}", True 'moves curser to the end
'SendKeys "{End}", True
'SendKeys "%nas{enter}", True 'to add default signature
'If GetNumlock() Then
' MsgBox "Num Lock is ON!"
'Else
' SendKeys "{NUMLOCK}"
'End If
Set MyMail = Nothing
Set MyOutlook = Nothing
DoCmd.SetWarnings True
DoCmd.Hourglass False
Dim varZ As Variant
varZ = MsgBox("Message sent successfully", vbInformation + vbOKOnly, gtstrAppTitle)
Exit_cmdSend:
Exit Sub
Err_cmdSend:
MsgBox Err.Description, vbExclamation, "cmdSend Error " & Err.Number
Resume Exit_cmdSend
End Sub