Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. Sub Test2()
  2. Dim OutApp As Object
  3. Dim OutMail As Object
  4. Dim cell As Range
  5.  
  6. Application.ScreenUpdating = False
  7. Set OutApp = CreateObject("Outlook.Application")
  8.  
  9. On Error GoTo cleanup
  10. For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
  11. If cell.Value Like "?*@?*.?*" And _
  12. LCase(Cells(cell.Row, "C").Value) = "yes" _
  13. And LCase(Cells(cell.Row, "D").Value) <> "send" Then
  14.  
  15. Set OutMail = OutApp.CreateItem(0)
  16.  
  17. On Error Resume Next
  18. With OutMail
  19. .To = cell.Value
  20. .Subject = "Reminder"
  21. .Body = "Dear " & Cells(cell.Row, "A").Value _
  22. & vbNewLine & vbNewLine & _
  23. "A task is about to start in your 2016 Project Plan " & _
  24. "please see your 2016 Project Plan for more information." & _
  25. " Thanks."
  26. 'You can add files also like this
  27. '.Attachments.Add ("C:test.txt")
  28. .Send 'Or use Display
  29. End With
  30. On Error GoTo 0
  31. Cells(cell.Row, "D").Value = "send"
  32. Set OutMail = Nothing
  33. End If
  34. Next cell
  35.  
  36. cleanup:
  37. Set OutApp = Nothing
  38. Application.ScreenUpdating = True
  39. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement