How to create a task item programatically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

why am I not allowed to intanstiate a new task item?

TaskItem task_DC = new TaskItemClass();

This is the erro I get when building:

error CS0122:
'Microsoft.Office.Interop.Outlook.TaskItemClass.TaskItemClass()' is
inaccessible due to its protection level
 
Hi,

To create an Outlook task item programatically, you need to use the Outlook
application object's CreateItem method and pass in the OlItemType.olTaskItem
constant.

TaskItem task_DC = (TaskItem) myOutlookApp.CreateItem(OlItemType.olTaskItem)

you can also create it by using the Add method in the items collection of a task
folder where you want the new task item to reside.

// assuming that tasks contains the MAPIFolder for the Outlook tasks obtained
from the namespace object

TaskItem task_DC = (TaskItem) tasks.Items.Add(OlItemType.olTaskItem);

Hope this helps.
 
Back
Top