Sub Mail(msgdate)
If msgdate = "" Then Exit Sub 'quit if not variable set
Dim OutApp As Object
Dim OutMail As Object
Dim strbody, subline, bodytxt, sname, carbon, ename As String
Dim fso As Object: Set fso = CreateObject("Scripting.FileSystemObject")
sname = ActiveWorkbook.Name
carbon = ""
ename = "THIS IS YOUR EMAIL ADDRESS"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
If msgdate = "SIX" Then
strbody = "****** style=font-size:10pt;font-family:Arial>" & "Dear Someone" & "," & "<br> <br>" _
& sname & " has hit its 6 month expiry warning, do something"
subline = "SIX Month Expiry warning for " & sname
sensr = 1
On Error Resume Next
readr = True
deliverr = False
End If
If msgdate = "THREE" Then
strbody = "****** style=font-size:10pt;font-family:Arial>" & "Dear Someone" & "," & "<br> <br>" _
& sname & " has hit its 3 month expiry warning, do something"
subline = "THREE Month Expiry warning for " & sname
sensr = 1
On Error Resume Next
readr = True
deliverr = False
End If
If msgdate = "ONE" Then
strbody = "****** style=font-size:10pt;font-family:Arial>" & "Dear Someone" & "," & "<br> <br>" _
& sname & " has hit its 1 month expiry warning, do something"
subline = "WARNING - ONE Month Expiry warning for " & sname & " WHOOP! WHOOP! WARNING!"
sensr = 1
On Error Resume Next
readr = True
deliverr = False
End If
With OutMail
.To = ename
.cc = carbon
.BCC = ""
.Subject = subline
.HTMLBody = strbody
.Importance = 2
.ReadReceiptRequested = readr
.OriginatorDeliveryReportRequested = deliverr
.Sensitivity = sensr
.Display 'or use .send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub