jeudi 28 avril 2016

Error trying to create outlook taskitem in web server app ( mvc5)

  • Using VS 2013 on MVC 5 project.

I' trying to send a task to outlook from an email. I've read several posts about and so far I was able to compile the following code, but it fails when trying to create the TaskItem.

        public void SendTask()
        // This creates OK
        var OutlookApp = new Microsoft.Office.Interop.Outlook.Application();

        // RUN TIME error error here
        Outlook.TaskItem task = OutlookApp.Session.Application.CreateItem(Outlook.OlItemType.olTaskItem) as Outlook.TaskItem;

        task.Subject = "Tax Preparation";
        task.StartDate = DateTime.Parse("4/29/2016 8:00 AM");
        task.DueDate = DateTime.Parse("4/30/2016 8:00 AM");

Aucun commentaire:

Enregistrer un commentaire