OK I use the first code to time an event this may be an e-mail or report.
The second piece of code is for sending an e-mail automatically.
On Error GoTo ErrorHandler
Dim dtrunreport As Date
Dim dtCurTime As Date
dtrunreport = Format(#12:06:00 PM#, "hh:mm") Or Format(#12:07:00 PM#, "hh:mm")
dtCurTime = Format(Time(), "hh:mm")
If dtCurTime = dtrunreport Then
DoCmd.SendObject acSendReport, "No Assignment Report", acFormatHTML, "Brendan.Bartley@anpost.ie", "", "", "NO Assignment Report", "Suppliers with NO ASSIGNMENT", True
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End If
End Sub
Private Sub cmdsend_Click()
On Error GoTo ErrorHandler
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Dim outfile As String
Dim objol As New Outlook.Application
Dim objmail As MailItem
Set objol = New Outlook.Application
Set objmail = objol.CreateItem(olMailItem)
With objmail
.To = ""
.CC = ""
.Subject = ""
.Body = ""
.NoAging = True
.Display
End With
DoCmd.Close
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End If
End Sub
Brendan Bartley
|