Sub Main()
Dim r As Range, iCol1 As Integer, iCol2 As Integer, iCol As Integer
Dim bSend As Boolean, sSend As String
With Sheets("YourSheetName")
iCol1 = 3
iCol2 = .UsedRange.Columns.Count
For Each r In .Range(.[A2], .[A2].End(xlDown))
'now loop across
Debug.Print r.Value & "," & r.Offset(0, 1).Value
bSend = False
sSend = ""
For i = iCol1 To iCol2 - 1 Step 2
If r.Offset(0, i - 1).Value > [YOUR_DATE_REF] Then
bSend = True
sSend = sSend & .Cells(1, i).Value & vbTab & Format(r.Offset(0, i - 1).Value, "yyyy/mm/dd") & vbLf
r.Offset(0, i).Value = Now
End If
Next
Next
If dSend Then
'send the email here
CdoSend _
r.Offset(0, iCol2).Value, _
"FromEmailAddress", _
"ATTENTION: Requalification", _
sSend
End If
Next
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function CdoSend( _
MailTo As String, _
MailFrom As String, _
Subject As String, _
MessageText As String, _
Optional CC As String, _
Optional BCC As String, _
Optional FileAttachment As String) As Boolean
On Error GoTo CdoSend_Err
' This example use late binding, you don't have to set a reference
' You must be online when you run the sub
Dim iMsg As Object
Dim iConf As Object
Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "[b][red]yourmailserver.com[/red][/b]"
.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
.Update
End With
With iMsg
Set .Configuration = iConf
.To = MailTo
.CC = CC
.BCC = BCC
.FROM = MailFrom
.Subject = Subject
.TextBody = MessageText
If Len(FileAttachment & "") > 0 Then
'## Last make sure the file actually exists and send it!:
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(FileAttachment) Then
.AddAttachment FileAttachment
Else
'otherwise return that the send failed and exit function:
Debug.Print "[CdoSend.Error]=> File attachment path does not exist, quitting..."
CdoSend = False
Exit Function
End If
End If
'## Send zee message! ##
.sEnd
End With
Set fso = Nothing
Set iMsg = Nothing
Set iConf = Nothing
CdoSend = True
CdoSend_Exit:
Exit Function
CdoSend_Err:
Debug.Print "[CdoSend.Error(" & Err.Number & ")]=> " & Err.Description
CdoSend = False
Resume CdoSend_Exit
End Function