Advertisement
Guest User

button code

a guest
Jan 23rd, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. Private Sub CommandButton1_Click()
  2.  
  3. Dim OutApp As Object, OutMail As Object
  4. Dim rng As Range
  5. Dim StrBody As String
  6. StrBody = "Hi - see below ticket quality failures for last week:"
  7.  
  8.  
  9.  
  10. Application.ScreenUpdating = False
  11. Set OutApp = CreateObject("Outlook.Application")
  12. Set rng = Nothing
  13. On Error Resume Next
  14.  
  15.  
  16. Set rng = Sheets("Macaulay").Range("Maccy").SpecialCells(xlCellTypeVisible)
  17.  
  18.  
  19. On Error GoTo cleanup
  20.  
  21.  
  22.  
  23. Set OutMail = OutApp.CreateItem(0)
  24. On Error Resume Next
  25. With OutMail
  26. .To = "Macaulay.Kurlfinke@kennedyslaw.com"
  27. .Subject = "!TICKET QUALITY FAILURES!"
  28. .HTMLBody = StrBody & RangetoHTML(rng) & "<br><br> Let me know if there's any questions. <br><br> Regards,<br><br> Dumitru Reaboi"
  29.  
  30. .Display 'Or use .Send .Display
  31. End With
  32. On Error GoTo 0
  33. Set OutMail = Nothing
  34.  
  35.  
  36. cleanup:
  37. Set OutApp = Nothing
  38. Application.ScreenUpdating = True
  39.  
  40.  
  41. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement