Private Sub Workbook_Open()
Dim lRow As Integer
Dim i As Integer
Dim toDate As Date
Dim toList, CCList As String
Dim eSubject As String
Dim eBody As String
Dim OutApp, OutMail
With Application
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
End With
Sheets("LOG").Select
lRow = Cells(Rows.Count, 1).End(xlUp).Row
Set OutApp = CreateObject("Outlook.Application")
For i = 1 To lRow
If Cells(i, 3).Value = Date Then
Set OutMail = OutApp.CreateItem(0)
toList = Cells(i, 15)
CCList = Cells(i, 16)
eSubject = "Quality Alert " & Cells(i, 1)
eBody = "This is an auto-generated email ~ Quality Alert " & Cells(i, 1) & " at " & Cells(i, 11) & " is due for removal today."
On Error Resume Next
With OutMail
.To = toList
.CC = CCList
.BCC = ""
.Subject = eSubject
.Body = eBody
.bodyformat = 1
.Display
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Cells(i, 14) = "Mail Sent " & Date + Time
End If
Next i
Set OutApp = Nothing
ActiveWorkbook.Save
With Application
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
End With
Sheets("LOG").Range("A1").Select
End Sub