Option Explicit
Public Sub Check_Send_Reminders()
Dim lastRow As Long, r As Long
With Worksheets("Sheet1")
lastRow = .Cells(.Rows.Count, "C").End(xlUp).row
For r = 2 To lastRow
If DateDiff("d", Date, .Cells(r, "C").Value) >= 90 And DateDiff("d", Date, .Cells(r, "C").Value) <= 96 And IsEmpty(.Cells(r, "D").Value) Then
Send_Outlook_Email "Reminder", "Email body text", "email.address1@email.com", "email.address2@email.com"
.Cells(r, "D").Value = Date
End If
Next
End With
End Sub
Private Sub Send_Outlook_Email(subject As String, body As String, ToEmail As String, CCEmail As String)
Static OutlookApp As Object 'Outlook.Application
Dim objMail As Object 'Outlook.MailItem
If OutlookApp Is Nothing Then
On Error Resume Next
Set OutlookApp = GetObject(, "Outlook.Application")
On Error GoTo 0
If OutlookApp Is Nothing Then Set OutlookApp = CreateObject("Outlook.Application") 'New Outlook.Application
End If
Set objMail = OutlookApp.CreateItem(0) '0 = olMailItem
objMail.subject = subject
objMail.body = body
objMail.To = ToEmail
objMail.CC = CCEmail
objMail.Send
End Sub