I'm using the below code to fetch tasks from Outlook 2007
.
public class c_tasks : IDisposable
{
private Microsoft.Office.Interop.Outlook.Application objOutlook = null;
private Microsoft.Office.Interop.Outlook.NameSpace objNamespace = null;
private Microsoft.Office.Interop.Outlook.MAPIFolder objFolder = null;
private string strType; // this is type "Tasks"
private int iItemCounter;
public c_tasks()
{
objOutlook = new Microsoft.Office.Interop.Outlook.ApplicationClass();
objNamespace = objOutlook.GetNamespace("MAPI");
strType = "Tasks";
}
public void Dispose()
{
if (objOutlook != null) objOutlook.Quit();
}
public void iGetAllTaskItems()
{
int iReturn = 0;
Microsoft.Office.Interop.Outlook.TaskItem item;
try
{
objFolder = objNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderTasks);
item = (Microsoft.Office.Interop.Outlook.TaskItem)objFolder.Items[1];
for (int ii = 2; ii <= objFolder.Items.Count; ii++)
{
string sub = item.Subject;
string own = item.Owner;
}
}
catch (System.Exception e)
{
}
return iReturn;
}
}
It works fine and I'm getting a result. But suppose I have 2 Users
in the Outlook data. How do you retrieve tasks specific to a particular user?
using Outlook = Microsoft.Office.Interop.Outlook;
public static List<Outlook.TaskItem> Aufgaben = new List<Outlook.TaskItem>();
Take my code
Outlook.MAPIFolder task = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks);
foreach (Outlook.TaskItem task2 in task.Items)
{
//MessageBox.Show(task2.ConversationTopic);
Aufgaben.Add(task2);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With