Option Explicit
'Sub Auto_Open()
Sub CheckForExpiryDates()
Dim ce As Range, i As Long
Dim OutApp As Object
Dim OutMail As Object
Dim strto As String, strcc As String, strbcc As String
Dim strsub As String, strbody As String
For i = 3 To Sheets("EXPORT").Range("e65536").End(xlUp).row
If Cells(i, 28).Value <= Date + 0 And Cells(i, 29) = "" Then '28 = Due Date , 29 = Payment
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With Sheets("EXPORT")
strto = .Cells(i, 44).Value '44 = email address
strcc = "" '.Cells(i, 44).Value
strbcc = ""
strsub = "AutoMail: NON PAYMENT"
strbody = "Hi" & " " & .Cells(i, 13).Value & vbNewLine & vbNewLine & _
"The Bill for Invoice no." & " " & .Cells(i, 3).Value & " " & _
"; Customer :" & " " & .Cells(i, 1).Value & " " & _
"is due on " & .Cells(i, 28).Value & _
" " & vbNewLine & vbNewLine & _
"Please request your customer to expedite payment!!!" & _
vbCrLf & vbCrLf & _
"If shipment have been arrange, please inform the PIC to update shipment date." & _
vbCrLf & vbCrLf & _
"Thank you."
'.Cells(i, 16) = Now()
End With
With OutMail
.To = strto
.CC = strcc
.BCC = strbcc
.Subject = strsub
.Body = strbody
'.Send
.display
End With
Set OutMail = Nothing
Set OutApp = Nothing
End If
Next i
End Sub
Bookmarks