Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'This is the main function
- Sub notify()
- Dim rng As Range
- For Each rng In Range("F3:F14")
- If (rng.Value = 1) Then
- Call mymacro
- End If
- Next rng
- End Sub
- -----------------------------------------------------------------------
- 'This is the function that sends an email when called by the main function
- Private Sub mymacro()
- Dim xOutApp As Object
- Dim xOutMail As Object
- Dim xMailBody As String
- Set xOutApp = CreateObject("Outlook.Application")
- Set xOutMail = xOutApp.CreateItem(0)
- xMailBody = "Hi there" & vbNewLine & vbNewLine & _
- "This is line 1" & vbNewLine & _
- "This is line 2"
- On Error Resume Next
- With xOutMail
- .To = "email address"
- .CC = ""
- .BCC = ""
- .Subject = "test succeeded"
- .Body = xMailBody
- .Display 'or use .Send
- End With
- On Error GoTo 0
- Set xOutMail = Nothing
- Set xOutApp = Nothing
- End Sub
Add Comment
Please, Sign In to add comment