M
mwang
I need to mail a reminder twice a day at intervals.this i have done as long
as my excel is open and the code which i had put in the code module,
Public RunWhen As Double
Public Const cRunIntervalhour = 5
Public Const cRunWhat = "mycode" ' the name of the procedure to run
Sub StartTimer()
RunWhen = Now + TimeSerial(cRunIntervalhour, 0, 0)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=True
End Sub
Sub mycode()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "..................." ' the ids to which i need to mail the
reminder
.CC = ""
.BCC = ""
.Subject = "Timesheet_remainder"
.HTMLBody = "Hi All" & "" & "Please finalize the TRS both in iPTS
and People Soft for this week" & " " & "Thank You"
.Send
End With
StartTimer
End Sub
this I have to run everyday each time opening my excel. I need suggestions
to make my macro run automatically when the excel is still closed.
also plz suggest me how to do this from my outlook
as my excel is open and the code which i had put in the code module,
Public RunWhen As Double
Public Const cRunIntervalhour = 5
Public Const cRunWhat = "mycode" ' the name of the procedure to run
Sub StartTimer()
RunWhen = Now + TimeSerial(cRunIntervalhour, 0, 0)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=True
End Sub
Sub mycode()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "..................." ' the ids to which i need to mail the
reminder
.CC = ""
.BCC = ""
.Subject = "Timesheet_remainder"
.HTMLBody = "Hi All" & "" & "Please finalize the TRS both in iPTS
and People Soft for this week" & " " & "Thank You"
.Send
End With
StartTimer
End Sub
this I have to run everyday each time opening my excel. I need suggestions
to make my macro run automatically when the excel is still closed.
also plz suggest me how to do this from my outlook