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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top