views:

34

answers:

3

In windows mobile, if you create a task, you can set a due date and a time to remind you about the task.

When the time is ready to remind you about the task, windows mobile will play a sound and show a user notification, which persists until you dismiss it.

Now I'd like to know if any task (how many?) has run into this "remind me" stage.

My first try was SystemState.TasksOverdue, but these are not the tasks the system reminds you about, these are the tasks which missed their due-date, which is something different. Same about the other SystemSta.Tasks... properties: none of them is about tasks which the system wants to remind you about.

Is there any way to get the tasks the system is actively reminding you right now?

Oh, I program using c# and .Net CF 2.0.

A: 

I have no experience with this myself, but my guess would be to look at the TaskCollection which returns a list of current tasks. By looping through that you can look at the ReminderSet, ReminderTime and StartDate properties of the Task class to determine which tasks are currently in the 'reminding stage'.

int activeRemindingTasks = 0;
OutlookSession session = new OutlookSession();

for (Task t in session.Tasks.Items)
{
  if (t.ReminderSet && t.ReminderTime <= DateTime.Now)
  {
    activeRemindingTasks++;
  }
}

The only thing I don't know is what happens when a user dismisses the reminders, rather than snoozing them. I assume that the ReminderSet or ReminderRepeat property of the Task object will then return false, but you'll have to check if that is what happens.

tomlog
I tried this (using ReminderTime instead of StartDate, of course), but for my tasks ReminderSet was always true, even for dismissed tasks, so this does not work for me.
Sam
@Sam: what about ReminderRepeat? And you're saying that ReminderTime is returning the time when the first reminder will be given? (just so I can edit my answer)
tomlog
ReminderRepeat is always false for my tasks, no matter if they are active, dismissed or in the future. And ReminderTime is always set to the datetime I entered for the task, does not change at all.There seems to be some other location where windows mobile keeps track of these.
Sam
Shane Powell
A: 

You use the CeSetUserNotficiationEx API. I'm not sure if there is a C# version of this API, but you should be able to P/Invoke it easy enough.

Another way is to use the CeRunAppAtTime to run/notify your app of the event and to display the notification yourself. You could then use the more fancy SHNotificationAdd API. The SHNotificationAdd is only available on ppc devices (Touch Screen).

Sorry, I misread the question so my answer is not correct.

Shane Powell
+1  A: 

The answer to this question might help, you could try going through the active notifications and see if you can detect which ones are tasks?

Matt
Jup, thats why I asked that question, after reading the first answers to this :)
Sam
(Kind of funny to get my own question refered as possible answer)
Sam
Oops, sorry didn't notice you asked that one too, I was thinking at the time that it was a bit of a coincidence that I had just read about an answer to this question a few questions back :)
Matt