I've been working on a project to allow people to access their Outlook tasks online via a web browser and be able to mark these tasks as "Complete" without the need to go into Outlook to do this. This has been achieved using EWS in C#.
However there is a funny bug where if you mark a task as "Complete" via the web application and if you go into Outlook and try to update the status of that task (e.g. mark it as still in progress), the task still displays as being striked out.
If you mark a task as complete directly from Outlook, the strikethrough will be displayed for that task in the list and if you "uncomplete" it then the strikethrough will disappear. This is NOT happening for tasks being marked as complete from the web app.
This is my code that I use to mark a task as complete:
protected override bool ActionTask(ActionArgs data)
{
ConnectToServer();
//Create Identifier of task item to update
var itemId = new ItemIdType
{
Id = data.Id,
ChangeKey = GetChangeKey(data.Id) //Need to grab task's change key
};
//Create task item to hold a set update
var setStatusTask = new TaskType
{
Status = TaskStatusType.Completed,
StatusSpecified = true
};
//Create set update
var setItemField = new SetItemFieldType
{
Item = new PathToUnindexedFieldType(),
Item1 = setStatusTask
};
(setItemField.Item as PathToUnindexedFieldType).FieldURI = UnindexedFieldURIType.taskStatus;
//Create the update request.
UpdateItemType updateItemRequest = new UpdateItemType();
updateItemRequest.ItemChanges = new ItemChangeType[1];
var itemChange = new ItemChangeType()
{
Item = itemId,
Updates = new ItemChangeDescriptionType[1]
};
itemChange.Updates[0] = setItemField;
updateItemRequest.ItemChanges[0] = itemChange;
UpdateItemResponseType updateItemResponse = ExchangeServiceBinding.UpdateItem(updateItemRequest);
if (updateItemResponse.ResponseMessages.Items.Length > 0)
return (updateItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success);
return false;
}
I cannot for the life of me figure out if there's something missing in my code or if this is simply just a strange Outlook bug.
Thanks heaps. :)