The
Process.GetProcessesByName[
^] method can test for a running instance of Outlook for you. If it's running then you can take the
Process
object that's returned and subscribe to the
Exited[
^] event. From here, you can look at the
Process
object again and use the
StartTime[
^] and
ExitTime[
^] properties to calculate whatever you want about it's run time and then save that to file.
The easiest way to do periodic File IO is with the static methods of the
File[
^] class.
Abhinav gave you a good link about how to make your service wake up and do something periodically.