作为“EWS托管API新手”,我在查找有关创建和管理任务的示例和文档时遇到了一些问题.
我已经设法为自己创建了一个没有问题的任务.但是,我真的需要能够做到以下几点 – 如果有人能给我任何指示,我真的很感激…
>创建任务并将其分配给其他用户.
>能够在分配给该用户时查询该任务的状态(完成百分比等).
>随时更新任务说明.
提前感谢任何指针!
解决方法
this post中的代码对我有用
为后代粘贴代码:
public string CreateTaskItem(string targetMailId) { string itemId = null; task.Subject = "Amit: sample task created from SDE and EWS"; task.Body = new BodyType(); task.Body.BodyType1 = BodyTypeType.Text; task.Body.Value = "Amit created task for you!"; task.StartDate = DateTime.Now; task.StartDateSpecified = true; // Create the request to make a new task item. CreateItemType createItemRequest = new CreateItemType(); createItemRequest.Items = new NonEmptyArrayOfAllItemsType(); createItemRequest.Items.Items = new ItemType[1]; createItemRequest.Items.Items[0] = task; /** code from create appointment **/ DistinguishedFolderIdType defTasksFolder = new DistinguishedFolderIdType(); defTasksFolder.Id = DistinguishedFolderIdNameType.tasks; defTasksFolder.MailBox = new EmailAddressType(); defTasksFolder.MailBox.EmailAddress = targetMailId; TargetFolderIdType target = new TargetFolderIdType(); target.Item = defTasksFolder; createItemRequest.SavedItemFolderId = target; try { // Send the request and get the response. CreateItemResponseType createItemResponse = _esb.CreateItem(createItemRequest); // Get the response messages. ResponseMessageType[] rmta = createItemResponse.ResponseMessages.Items; foreach (ResponseMessageType rmt in rmta) { ArrayOfRealItemsType itemArray = ((ItemInfoResponseMessageType)rmt).Items; ItemType[] items = itemArray.Items; // Get the item identifier and change key for each item. foreach (ItemType item in items) { //the task id Console.WriteLine("Item identifier: " + item.ItemId.Id); //the change key for that task,would be used if you want to track changes ... Console.WriteLine("Item change key: " + item.ItemId.ChangeKey); } } } catch (Exception e) { Console.WriteLine("Error Message: " + e.Message); } return itemId; }