Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Test2()
- Dim OutApp As Object
- Dim OutMail As Object
- Dim cell As Range
- Application.ScreenUpdating = False
- Set OutApp = CreateObject("Outlook.Application")
- On Error GoTo cleanup
- For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
- If cell.Value Like "?*@?*.?*" And _
- LCase(Cells(cell.Row, "C").Value) = "yes" _
- And LCase(Cells(cell.Row, "D").Value) <> "send" Then
- Set OutMail = OutApp.CreateItem(0)
- On Error Resume Next
- With OutMail
- .To = cell.Value
- .Subject = "Reminder"
- .Body = "Dear " & Cells(cell.Row, "A").Value _
- & vbNewLine & vbNewLine & _
- "A task is about to start in your 2016 Project Plan " & _
- "please see your 2016 Project Plan for more information." & _
- " Thanks."
- 'You can add files also like this
- '.Attachments.Add ("C:test.txt")
- .Send 'Or use Display
- End With
- On Error GoTo 0
- Cells(cell.Row, "D").Value = "send"
- Set OutMail = Nothing
- End If
- Next cell
- cleanup:
- Set OutApp = Nothing
- Application.ScreenUpdating = True
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement