我正在使用以下代码从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;
}
}
它正常工作,我正在获得结果。但是假设在Outlook数据中有2个用户
,如何检索与特定用户相关的任务?