Option Explicit
Sub Send_email_under_90()
Dim OutApp As Object
Dim OutMail As Object
Dim rCell As Range
Dim body As String
Dim colCustomer As Integer 'Customer column
Dim colTimeTillDue As Integer 'Time until due column
Dim colTransport As Integer 'Transport column
Dim colDandO As Integer 'D&O column
Dim colCyber As Integer 'Cyber column
Dim colCrime As Integer 'Crime column
Dim colArt As Integer 'Art column
Dim colName As Integer 'Name in charge column
Dim colEmail As Integer 'Email column
colCustomer = 6
colTimeTillDue = 8
colTransport = 9
colDandO = 10
colCyber = 11
colCrime = 12
colArt = 13
colName = 15
colEmail = 16
For Each rCell In Range(Cells(3, colTimeTillDue), Cells(Rows.Count, colTimeTillDue).End(xlUp))
If rCell.Value < 91 Then
'Build body message
body = "Dear " & Cells(rCell.Row, colName).Text & ",<br><br>"
body = body & "It is soon time for renewal for " & Cells(rCell.Row, colCustomer).Text
body = body & ". The following standard terms of renewal are:<br>"
If Cells(rCell.Row, colTransport).Text <> "" Then
body = body & "Transport: " & Cells(rCell.Row, colTransport).Text & "<br>"
End If
If Cells(rCell.Row, colDandO).Text <> "" Then
body = body & "D&O: " & Cells(rCell.Row, colDandO).Text & "<br>"
End If
If Cells(rCell.Row, colCyber).Text <> "" Then
body = body & "Cyber: " & Cells(rCell.Row, colCyber).Text & "<br>"
End If
If Cells(rCell.Row, colCrime).Text <> "" Then
body = body & "Crime: " & Cells(rCell.Row, colCrime).Text & "<br>"
End If
If Cells(rCell.Row, colArt).Text <> "" Then
body = body & "Art: " & Cells(rCell.Row, colArt).Text & "<br>"
End If
body = body & "<br>Please let me know if they will be renewing under these terms.<br><br>Thank you!<br><br>Sincerely X"
'open outlook if OutApp hasn't been set to the Outlook App yet
If OutApp Is Nothing Then
Set OutApp = CreateObject("Outlook.Application")
End If
'Create email and display
'The email can be automatically sent instead if ".Display" is replaced with ".Send"
Set OutMail = OutApp.CreateItem(0)
With OutMail
.Subject = "Renewal"
.To = Cells(rCell.Row, colEmail).Text
.htmlbody = body
.display
End With
Set OutMail = Nothing
End If
Next rCell
Set OutApp = Nothing
End Sub