Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub SendEmail()
- Dim OutApp As Object
- Dim OutMail As Object
- Set OutApp = CreateObject("Outlook.Application")
- Set OutMail = OutApp.CreateItem(0)
- With OutMail
- .To = "yourmail"
- .CC = ""
- .BCC = ""
- .Subject = "Report"
- .Body = "Hello!"
- .Attachments.Add ActiveWorkbook.FullName
- .Send
- End With
- Set OutMail = Nothing
- Set OutApp = Nothing
- Application.OnTime TimeValue("17:00:00"), "SendEmail"
- End Sub
- Sub Workbook_Open()
- Application.OnTime TimeValue("17:00:00"), "SendEmail"
- End Sub
- Sub SetSchedule()
- Application.OnTime TimeValue("17:00:00"), "SendEmail"
- Application.OnTime TimeValue("23:59:00"), "SetSchedule"
- End Sub
- Sub Workbook_Open()
- Call SetSchedule
- End Sub
- Option Explicit
- Private Sub Application_Reminder(ByVal item As Object)
- ' Now call your VBA Code
- End Sub
Add Comment
Please, Sign In to add comment