6

我正在使用下面的代码从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;
        }
    }

它工作正常,我得到了结果。但假设我有2 UsersOutlook 数据。如何检索特定用户的特定任务?

4

2 回答 2

1
  1. 绑定使用 =using Outlook = Microsoft.Office.Interop.Outlook;
  2. 创建列表 =public static List<Outlook.TaskItem> Aufgaben = new List<Outlook.TaskItem>();
  3. 拿我的代码

         Outlook.MAPIFolder task = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks);
        foreach (Outlook.TaskItem task2 in task.Items)
        {
            //MessageBox.Show(task2.ConversationTopic);
            Aufgaben.Add(task2);
        }
    
  4. 开心点 :D
于 2014-08-08T09:13:33.143 回答
0

您的程序将在某些用户的凭据下运行。当您调用 GetDefaultFolder 时,它会检索该用户的任务。

为了检索其他用户的任务,您必须调用GetSharedDefaultFolder,并且当前用户必须有权打开该共享文件夹。请注意 GetSharedDefaultFolder 链接的备注部分,您无法使用该方法访问一些特殊文件夹。

于 2013-01-09T16:39:08.393 回答