here is my current code:
When I run this code on my machine, and there are work orders to be exported it opens the outlook warning windows and everything (which is fine), i say yes to all of them, but it never actually sends the message.
When I run this on a test environment (using Access runtime), it gives me the error "The expression On Click you entered as the event property setting produced the following error: The operation on the | object failed."
Does anyone know what's causing the email not to send on my end, or why it fails to even attempt on the runtime end?
Thanks for any help.
-Pete
Code:
Private Sub cmdExportFile_Click()
If DCount("TicketNum", "qryExport", "Prefix='000'") < 1 Then
Call MsgBox("There are no new work orders to export.", vbOKOnly)
Exit Sub
End If
If MsgBox("Are you sure you want to export and e-mail the new work orders?", vbYesNo, "Export and Email?") Then
DoCmd.TransferText acExportDelim, , "qryExport", "G:\ServiceTech\Exports\EXPORT" & Format(Date, "yyyymmdd") & "_" & Format(Time(), "hhmm") & ".csv"
DoCmd.SetWarnings False
DoCmd.OpenQuery "qrySetAsExported", acViewNormal
DoCmd.SetWarnings True
Dim appOutlook As Object
Set appOutlook = CreateObject("Outlook.Application")
Set MailOutLook = appOutlook.CreateItem(0)
With MailOutLook
'replaced to protect
.Recipients.Add ("***@***.***")
.Subject = "New Work Orders. Exported " & Format(Date, "yyyymmdd") & "_" & Format(Time(), "hhmm")
.Body = "These are the new work orders that were entered on the office side of the Service Tech System."
.Attachments.Add "G:\ServiceTech\Exports\EXPORT" & Format(Date, "yyyymmdd") & "_" & Format(Time(), "hhmm") & ".csv"
.Send
End With
End If
End Sub
When I run this code on my machine, and there are work orders to be exported it opens the outlook warning windows and everything (which is fine), i say yes to all of them, but it never actually sends the message.
When I run this on a test environment (using Access runtime), it gives me the error "The expression On Click you entered as the event property setting produced the following error: The operation on the | object failed."
Does anyone know what's causing the email not to send on my end, or why it fails to even attempt on the runtime end?
Thanks for any help.
-Pete