none
[E2010] [EWSMA] [C#] [Windows]: How do I get Tasks to show up in the Calendar view RRS feed

  • Question

  • When creating a task from EWS, the Owner field is empty.  I believe this causes my created Task to disappear when I am in the Calendar view (showing Tasks on the bottom).  The created Task still shows up in the Tasks view, but not the Calendar view (where Tasks are on the bottom).

    Creating a task in Outlook shows it on the Calendar view, but creating a Task with the same values from EWS does not show it there.  The only difference is the Owner field of the Task, which is read-only in EWS.  Can we set this somehow?

    ExchangeService ews;
    ews = new ExchangeService();
    ews.UseDefaultCredentials = true;
    ews.AutodiscoverUrl("my_email@company.com");
    
    Task taskItem = new Task(ews);
    taskItem.Subject = "subject";
    taskItem.Body = "body";
    taskItem.IsReminderSet = true;
    taskItem.ReminderDueBy = DateTime.Now;
    taskItem.StartDate = DateTime.Now;
    
    taskItem.Save();
    
    
    

    Thanks,

    -Daniel

    Saturday, December 28, 2013 6:42 PM

Answers

  • Issue resolved!  Apparently the order that you set properties on the TaskItem matters.  By changing the order the task now appears in daily tasks.  This also fixed issues I had with the due by time in the reminder prompt.

    Task taskItem = new Task(ews); // OLD taskItem.IsReminderSet = true; taskItem.ReminderDueBy = DateTime.Now; taskItem.StartDate = DateTime.Now.Date; taskItem.DueDate = DateTime.Now.Date; // NEW taskItem.StartDate = DateTime.Now.Date; taskItem.DueDate = DateTime.Now.Date; taskItem.ReminderDueBy = DateTime.Now;

    taskItem.IsReminderSet = true;


    Thanks Glen!

    • Marked as answer by dblackker Tuesday, December 31, 2013 4:37 PM
    Tuesday, December 31, 2013 4:37 PM

All replies

  • You need to set the PidLidToDoOrdinalDate http://msdn.microsoft.com/en-us/library/ee124268(v=exchg.80).aspx property for a Task you create to appear in the Calendar view eg

                taskItem.Body = "body";
                taskItem.IsReminderSet = true;
                taskItem.ReminderDueBy = DateTime.Now;
                taskItem.StartDate = DateTime.Now;
                taskItem.DueDate = DateTime.Now.AddDays(1);
                ExtendedPropertyDefinition PidLidToDoOrdinalDate = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Common, 0x85A0, MapiPropertyType.SystemTime);
                taskItem.SetExtendedProperty(PidLidToDoOrdinalDate,DateTime.Now.AddDays(1));
                taskItem.Save();
    Cheers
    Glen

    Monday, December 30, 2013 5:47 AM
  • Thanks Glen! This is definitely a step in the right direction, but I still don't see the task appear.  Are there any additional properties that need to be set?

    -Daniel

    Monday, December 30, 2013 2:19 PM
  • The items show up in the TODO lists on the various views, but not in the Daily Task List in the Calendar view.
    Monday, December 30, 2013 3:01 PM
  • I can sort of reproduce what your talking about I think its because your setting the Start and Due date to the same time which seems to affect the search folder that's used for the view. The following seems to work okay for me

                Task taskItem = new Task(service);
                taskItem.Subject = "Created From qqq";
                taskItem.Body = "body";
                taskItem.IsReminderSet = true;
                taskItem.ReminderDueBy = DateTime.Now;
                taskItem.StartDate = DateTime.Now;
                taskItem.DueDate = DateTime.Now.AddHours(1);
                taskItem.Status = TaskStatus.NotStarted;
                ExtendedPropertyDefinition PidLidToDoOrdinalDate = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Common, 0x85A0, MapiPropertyType.SystemTime);
                taskItem.SetExtendedProperty(PidLidToDoOrdinalDate, DateTime.Now.AddHours(1));
                ExtendedPropertyDefinition FlagDueBy = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Common, 0x8560, MapiPropertyType.SystemTime);
                taskItem.SetExtendedProperty(FlagDueBy, DateTime.Now.AddHours(1));
                taskItem.Save();
    Cheers
    Glen

    Tuesday, December 31, 2013 11:26 AM
  • Copying this exact code still doesn't create a task in the Daily Task list.  Is there any reason an ExtendedProperty would not work?

    When I set PidLidToDoTitle, the tickler title in the Task list doesn't reflect what I set the extended property to.

    Tuesday, December 31, 2013 2:50 PM
  • Issue resolved!  Apparently the order that you set properties on the TaskItem matters.  By changing the order the task now appears in daily tasks.  This also fixed issues I had with the due by time in the reminder prompt.

    Task taskItem = new Task(ews); // OLD taskItem.IsReminderSet = true; taskItem.ReminderDueBy = DateTime.Now; taskItem.StartDate = DateTime.Now.Date; taskItem.DueDate = DateTime.Now.Date; // NEW taskItem.StartDate = DateTime.Now.Date; taskItem.DueDate = DateTime.Now.Date; taskItem.ReminderDueBy = DateTime.Now;

    taskItem.IsReminderSet = true;


    Thanks Glen!

    • Marked as answer by dblackker Tuesday, December 31, 2013 4:37 PM
    Tuesday, December 31, 2013 4:37 PM