1
votes

I have read several posts and got a solution that use Microsoft.Office.Interop.Outlook to work to create a task in Outlook. Here is the code that will create a task in outlook for my user.

    public void CreateOutlookTask() 
    {
        Application outlookApp = new Application();
        TaskItem oTask = outlookApp.CreateItem(OlItemType.olTaskItem);
        Inspector oInspector = oTask.GetInspector;
        oTask.Subject = "This is my task subject";
        oTask.DueDate = Convert.ToDateTime("06/25/2011");
        oTask.StartDate = Convert.ToDateTime("06/20/2011");
        oTask.ReminderSet = true;
        oTask.ReminderTime = Convert.ToDateTime("06/28/2006 02:40:00 PM");
        oTask.Body = "This is the task body";
        oTask.Status =OlTaskStatus.olTaskInProgress;
        oTask.Save();  
    }

I still have two issues with the above code.

1) It will only create tasks for the user that is running the application. I hope to create tasks from a web app, so I need to be able to log into each users account because the web app will not have an outlook account.

2) Using Microsoft.Office.Interop.Outlook requires that outlook is installed. I would really like a solution that doesn't require outlook to be installed on the machine, but haven't found one.

Any help on the above two issues would be greatly appreciated.

2

2 Answers

0
votes

You can use exchange web services to create items such as this without the need of the interop libraries.

Get started with EWS client applications

0
votes

If using OOM is still an option, you can use Application.Session.GetSharedDefaultFolder to retrieve the default Tasks folder of another Exchange user. You can then create a new task there using MAPIFolder.Items.Add.