Carlandrewlewis
asked on
Excel - Email Notifications Reminders
I have a sheet that i have email notifications in. At the moment it sends an email if the date in column K is passed by 7 days. What i can't figure out is how to record the date that a 1st reminder is sent in column L and if necessary a second reminder in column M. After this the emails will need to stop being sent.
Job-Spreadsheet-2008.xls
Job-Spreadsheet-2008.xls
ASKER
I have tried and it doesn't seem to do anything?? Here is code for one that i already use but i don't know how to copy it across so it applies...
Sub sendRemindersForWorksheet( ByRef ws As Worksheet)
Dim row As Long, i As Long, n As Long
Dim sReminder As String, sMessage As String
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim datLast As Date, datNext As Date
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Appl ication")
OutApp.Session.Logon
On Error GoTo cleanup
n = ws.Cells(Rows.Count, 1).End(xlUp).row
For row = 2 To n
sReminder = ""
datLast = Application.Max(ws.Rows(ro w))
datNext = datLast + 30
If datLast > 0 Then
i = ws.Rows(row).Find(datLast) .Column
Select Case Date - datLast
Case Is >= 30
If ws.Cells(row, i + 2) = "" Then
sReminder = "Last" 'Needs the Last reminder
ws.Cells(row, i + 2).Value = sReminder & Format(Date, " d/m") ' mark as sent
End If
Case Is >= 15
If ws.Cells(row, i + 1) = "" Then
sReminder = "1st" 'Needs the 1st reminder
ws.Cells(row, i + 1).Value = sReminder & Format(Date, " d/m") ' mark as sent
End If
End Select
If sReminder <> "" Then
sMessage = ws.Cells(row, 1) & " " & ws.Cells(row, 2) & " in van " & ws.Cells(row, 3) & _
" needs a new van air test by " & Format(datNext, "d mmmm")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "test@test.co.uk" 'Please put in the correct e-mail address
.Subject = sReminder & " Reminder for " & sMessage
.Body = "Dear Carl" & vbNewLine & vbNewLine & "Please note that " & sMessage
.Send
End With
End If
End If
Next
Set OutMail = Nothing
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Sub sendRemindersForWorksheet(
Dim row As Long, i As Long, n As Long
Dim sReminder As String, sMessage As String
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim datLast As Date, datNext As Date
Application.ScreenUpdating
Set OutApp = CreateObject("Outlook.Appl
OutApp.Session.Logon
On Error GoTo cleanup
n = ws.Cells(Rows.Count, 1).End(xlUp).row
For row = 2 To n
sReminder = ""
datLast = Application.Max(ws.Rows(ro
datNext = datLast + 30
If datLast > 0 Then
i = ws.Rows(row).Find(datLast)
Select Case Date - datLast
Case Is >= 30
If ws.Cells(row, i + 2) = "" Then
sReminder = "Last" 'Needs the Last reminder
ws.Cells(row, i + 2).Value = sReminder & Format(Date, " d/m") ' mark as sent
End If
Case Is >= 15
If ws.Cells(row, i + 1) = "" Then
sReminder = "1st" 'Needs the 1st reminder
ws.Cells(row, i + 1).Value = sReminder & Format(Date, " d/m") ' mark as sent
End If
End Select
If sReminder <> "" Then
sMessage = ws.Cells(row, 1) & " " & ws.Cells(row, 2) & " in van " & ws.Cells(row, 3) & _
" needs a new van air test by " & Format(datNext, "d mmmm")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "test@test.co.uk" 'Please put in the correct e-mail address
.Subject = sReminder & " Reminder for " & sMessage
.Body = "Dear Carl" & vbNewLine & vbNewLine & "Please note that " & sMessage
.Send
End With
End If
End If
Next
Set OutMail = Nothing
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Carlandrewlewis
Any Update?
Chris
Any Update?
Chris
ASKER
Chris, sorry for the major delay, i have been working away therefore not been able to confirm this. Anyway thanks for your help!!!
Open in new window