Hi
I have recently located someones coding from these pages to send emails based on specific due dates. I was provided with the below code which sort of works, however, if the code identifies more than one person with the same end date, it only shows the email for the last person listed. The code will update the spreadsheet to say it has identified and created an email however, it will only show 1 x pane to be sent and not the seven it has identified.
ANY HELP WOULD BE APPRECIATED
Private Sub Workbook_Open()
Dim i As Long
Dim OutApp, OutMail As Object
Dim strto, strcc, strbcc, strsub, strbody As String
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
For i = 2 To Range("C65536").End(xlUp).Row
If Cells(i, 43) <> "Y" Then
If Cells(i, 21) - 14 < Date Then
strto = Cells(i, 44).Value 'email address
strsub = "PSR Contractor " & Cells(i, 6).Value & " is due on Due date " & Cells(i, 21).Value 'email subject
strbody = "Dear " & Cells(i, 6).Value & vbNewLine & "please update your project status" 'email body
With OutMail
.To = strto
.Subject = strsub
.Body = strbody
'.Send
.display
End With
On Error Resume Next
Cells(i, 42) = "Mail Sent " & Now()
Cells(i, 43) = "Y"
End If
End If
Next
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Bookmarks