try this
add some email addresses in col AM for testing...
instead of using the button you can add the code into
Private Sub Workbook_Open()
'
'
'your code
End Sub
and it's activated when you open the workbook.
Sub Button1_Click()
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
Dim MyName As String
Application.ScreenUpdating = 0
For Each ws In Worksheets
MyName = ThisWorkbook.Name
For i = Range("ae65536").End(xlUp).Row To 2 Step -1
If Cells(i, 31) = Date Then
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With ws 'Sheets("1.2013")
strto = .Cells(i, 39).Value 'email address from column am
strcc = ""
strbcc = ""
strsub = MyName
strbody = "Hi there," & "pls see" & " " & MyName & vbNewLine & vbNewLine & _
.Cells(i, 1).Value & " " & _
"needs an updated...." & " " & .Cells(i, 7).Value & " " & _
"because..." & " " & .Cells(i, 11).Value & "." & _
vbCrLf & vbCrLf & "Thank you."
'need to change the column for your text....
End With
With OutMail
.To = strto
.CC = strcc
.BCC = strbcc
.Subject = strsub
.Body = strbody
'.Send
.display
'color in red cells in col A when the email is sent and add date in col af
Cells(i, 1).Select
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
End With
Set OutMail = Nothing
Set OutApp = Nothing
End If
Next i
Next ws
Application.ScreenUpdating = 1
End Sub
Bookmarks