Question

I will accept C# code as well. Will just convert it to VB.NET.

I'm having trouble retrieving tasks from outlook.
I have an application that writes a task to outlook.
The application can also mark a task as completed... but this is where my problem comes in.
What I want to achieve at the end is to mark a task as completed in my application and then it should also be marked as completed in outlook.
This is the code I have tried so far to retrieve the tasks, but now I dont know how to iterate through them to be able to mark a specific task as completed:

Dim namespce As Outlook.NameSpace
Dim tasks As Outlook.Items
Dim oApp = New Outlook.Application

namespce = oApp.GetNamespace("MAPI")
tasks = namespce.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks).Items

For Each task As Object In tasks
    'From here on I dont know any more
Next
Was it helpful?

Solution

C# code:

foreach(Outlook.TaskItem task in tasks)
{
   bool isCompleeted = //Check if your task is compleeted in your application you could use EntryID property to identify a task 
   if(isCompleeted == true && task.Status != OlTaskStatus.olTaskComplete)
   {
       task.MarkComplete();
       task.Save();
   }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top