Visual Studio Developer Center > Visual Studio Forums > Visual Studio Tools for Office > Organize MS Outlook Tasks into calendar and task-hierarchy
Ask a questionAsk a question
 

AnswerOrganize MS Outlook Tasks into calendar and task-hierarchy

  • Saturday, November 07, 2009 2:37 PMsuperkuton Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I want to organize my task list using MS 2007 but I found it lacking the following features that I need:

    1. display tasks in the calendar
    2. allow tasks to have sub-tasks (much like a task-hierarchy)
    Any general idea on how do I solve these requirements using VS 2008 or Outlook VBA?
    (Btw, which is better to use for these requirements, VS or VBA?)

    Is there any similar existing add-in or project that has already been developed
    by the community that I can start on?

    a filipino newbie

Answers

  • Tuesday, November 10, 2009 3:51 AMBessie ZhaoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello,

    Originally, the tasks are stored in task folder. If want to display in the calendar folder, we could use ItemAdd event of task folder, and then move this task item to calendar folder. Code like this,

            Outlook.Items items;
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                //Outlook.TaskItem ti = this.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olTaskItem) as Outlook.TaskItem;
                //ti.Subject = "Test11";
                //ti.Save();
                Outlook.Folder folderTask = this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks) as Outlook.Folder;
                items = folderTask.Items;
                items.ItemAdd += new Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(items_ItemAdd);        
            }

            void items_ItemAdd(object Item)
            {
                Outlook.TaskItem ti = Item as Outlook.TaskItem;
                Outlook.MAPIFolder folder=Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.MAPIFolder;
                ti.Move(folder);
            }

    Now, when a task item is created and saved, it will be stored in task folder, and trigger ItemAdd event. Finally in this event handler, it will be moved to calendar folder.

    For VBA or VSTO, I think it is also can be achieved by using VBA. From this blog article, here I quote a statement, VBA is a scripting language supported in several Office applications, and VSTO is a Visual Studio enhancement to support .NET managed code development for Word and Excel documents and Outlook add-ins. Also you could refer to this article to get more insight about VBA. About VSTO, you could refer to this forum's PLEASE READ FIRST.

    Unfortunately, task hierarchy does not support by Outlook object model. For this, please refer to this blog, especially the comments, and this link.

    Best regards,
    Bessie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked As Answer bysuperkuton Sunday, November 15, 2009 12:14 PM
    •  

All Replies

  • Tuesday, November 10, 2009 3:51 AMBessie ZhaoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello,

    Originally, the tasks are stored in task folder. If want to display in the calendar folder, we could use ItemAdd event of task folder, and then move this task item to calendar folder. Code like this,

            Outlook.Items items;
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                //Outlook.TaskItem ti = this.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olTaskItem) as Outlook.TaskItem;
                //ti.Subject = "Test11";
                //ti.Save();
                Outlook.Folder folderTask = this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks) as Outlook.Folder;
                items = folderTask.Items;
                items.ItemAdd += new Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(items_ItemAdd);        
            }

            void items_ItemAdd(object Item)
            {
                Outlook.TaskItem ti = Item as Outlook.TaskItem;
                Outlook.MAPIFolder folder=Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.MAPIFolder;
                ti.Move(folder);
            }

    Now, when a task item is created and saved, it will be stored in task folder, and trigger ItemAdd event. Finally in this event handler, it will be moved to calendar folder.

    For VBA or VSTO, I think it is also can be achieved by using VBA. From this blog article, here I quote a statement, VBA is a scripting language supported in several Office applications, and VSTO is a Visual Studio enhancement to support .NET managed code development for Word and Excel documents and Outlook add-ins. Also you could refer to this article to get more insight about VBA. About VSTO, you could refer to this forum's PLEASE READ FIRST.

    Unfortunately, task hierarchy does not support by Outlook object model. For this, please refer to this blog, especially the comments, and this link.

    Best regards,
    Bessie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked As Answer bysuperkuton Sunday, November 15, 2009 12:14 PM
    •