Guest User

Untitled

a guest
Apr 20th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. Sub SendEmail()
  2.  
  3. Dim OutApp As Object
  4. Dim OutMail As Object
  5. Set OutApp = CreateObject("Outlook.Application")
  6. Set OutMail = OutApp.CreateItem(0)
  7.  
  8. With OutMail
  9. .To = "yourmail"
  10. .CC = ""
  11. .BCC = ""
  12. .Subject = "Report"
  13. .Body = "Hello!"
  14. .Attachments.Add ActiveWorkbook.FullName
  15.  
  16. .Send
  17. End With
  18.  
  19. Set OutMail = Nothing
  20. Set OutApp = Nothing
  21. Application.OnTime TimeValue("17:00:00"), "SendEmail"
  22.  
  23. End Sub
  24.  
  25. Sub Workbook_Open()
  26.  
  27. Application.OnTime TimeValue("17:00:00"), "SendEmail"
  28. End Sub
  29.  
  30. Sub SetSchedule()
  31.  
  32. Application.OnTime TimeValue("17:00:00"), "SendEmail"
  33.  
  34. Application.OnTime TimeValue("23:59:00"), "SetSchedule"
  35.  
  36. End Sub
  37.  
  38. Sub Workbook_Open()
  39.  
  40. Call SetSchedule
  41.  
  42. End Sub
  43.  
  44. Option Explicit
  45. Private Sub Application_Reminder(ByVal item As Object)
  46. ' Now call your VBA Code
  47.  
  48. End Sub
Add Comment
Please, Sign In to add comment