Tuesday, October 12, 2004

240.aspx

Pocket Outlook: catching up with old tasks

I frequently have more than 20 tasks due each day. Stuff that must get done in high priority, some low priority reminders and blog notes. On the PC I use an Outlook macro but there is no macro language on the Pocket PC so I used the modified Pocket Outlook .NET CF class library to catch up with old tasks.


// In the class declaration


private PocketOutlook.Application _pocketOutlook;


...


 


// Startup code in the form Load() routine     


_pocketOutlook = new PocketOutlook.Application();                      


_pocketOutlook.Logon();


 



 


/// <summary>


/// Catch up with task that are due in the past


/// </summary>


/// <param name="sender"></param>


/// <param name="e"></param>


private void menuCatchUp_Click(object sender, System.EventArgs e)


{                


      // Get all tasks due before today


      PocketOutlook.ItemCollection tasks = _pocketOutlook.GetDefaultFolder(olFolderTasks).Items;


      PocketOutlook.ItemCollection oldTasks = tasks.Restrict("[DueDate] < \"" + System.DateTime.Today.ToString("dd/MM/yy")+ "\" and [Complete]=False");


     


      // The list auto-updates so we go a while loop always working on the first item instead of


      // using a for loop


      int updatedItems = 0;


      while (oldTasks.Count > 0)


      {


            updatedItems++;


            PocketOutlook.Task task = (PocketOutlook.Task) oldTasks.Item(1);  // 1 based                   


            task.DueDate = System.DateTime.Today.;               


            task.Save();


      }


      System.Windows.Forms.MessageBox.Show("Updated " + updatedItems + " tasks.");             


 


      // Reload the task list


     


}


 


 

No comments:

Post a Comment