"Gwen" <Gw**@discussions.microsoft.com> wrote in message
news:99**********************************@microsof t.com...
Hi, I'm writing an add-in for outlook 2003 which automatically schedules
the
users tasks from the task list in to the calendar with respect to
priority. I
can sort the tasks by priority within the task list via;
_Items olTasks = olFolderTask.Items; // MSO items collection in folder
olTasks.Sort("[Priority]", true); // sort items by Priority before reading
int nTasksCount = olTasks.Count;
for (int i = 0; i < nTasksCount; ++i)
{
_TaskItem olItemTask;
try
{
if (i == 0) // Should be called first before
iteration start
olItemTask = (_TaskItem)olTasks.GetFirst(); //
First item
else
olItemTask = (_TaskItem)olTasks.GetNext(); //
second item
if (olItemTask.Complete) // Task allredy completed
continue;
however when I send these tasks to the calendar, the prioritsed order is
lost and the go in oder of task name instead. Any ideas?
I am not sure if this will help or not but is it possible to set the list of
items to the value of the sort so you have the following:
_Items olTasks = olFolderTask.Items; // MSO items collection in folder
olTasks.Sort("[Priority]", true); // sort items by Priority before reading
Could you try this instead.. Use a tmpTasks and set it like this
_Items tmpTasks = olTasks.Sort("[Priority]",true);
Then loop through using tmpTasks instead of olTasks for everything. The
tmpTasks should be in yoru order where olTasks might still really be in
their regular order.
I have seen this type of behavior before where when you call the .Sort
property it more than likely creates a type of view and doesn't really sort
the list so when you loop through it it is not in the correct order but in
the original order. Let me know if my test above does not fix your
problem. I have not tested this but hope it will help you out. Good
luck.
jjardine