Guest User

Untitled

a guest
Jan 16th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. 'This is the main function
  2.  
  3. Sub notify()
  4. Dim rng As Range
  5. For Each rng In Range("F3:F14")
  6. If (rng.Value = 1) Then
  7. Call mymacro
  8. End If
  9. Next rng
  10.  
  11. End Sub
  12. -----------------------------------------------------------------------
  13.  
  14. 'This is the function that sends an email when called by the main function
  15.  
  16. Private Sub mymacro()
  17. Dim xOutApp As Object
  18. Dim xOutMail As Object
  19. Dim xMailBody As String
  20. Set xOutApp = CreateObject("Outlook.Application")
  21. Set xOutMail = xOutApp.CreateItem(0)
  22. xMailBody = "Hi there" & vbNewLine & vbNewLine & _
  23. "This is line 1" & vbNewLine & _
  24. "This is line 2"
  25. On Error Resume Next
  26. With xOutMail
  27. .To = "email address"
  28. .CC = ""
  29. .BCC = ""
  30. .Subject = "test succeeded"
  31. .Body = xMailBody
  32. .Display 'or use .Send
  33. End With
  34. On Error GoTo 0
  35. Set xOutMail = Nothing
  36. Set xOutApp = Nothing
  37. End Sub
Add Comment
Please, Sign In to add comment