none
How to create task request for exchange user knowing only e-mail address ? RRS feed

  • Question

  • Hello

    Could you please help me with Exchange task request problem?

    I need to create task request for user. I can create a task for myself (user A) in the Exchange 2010 using code (see below, I've found it in the internet and it uses Exchange Web Service)

     

    using (var ews = new EWS.ExchangeServiceBinding())
    {
    	ews.Credentials = System.Net.CredentialCache.DefaultCredentials;
    	ews.Url = exchangeUrl; //ends with /EWS/Exchange.asmx
    
    	TaskType task = new TaskType();
    	task.Subject = taskSubject;
    	task.Body = new BodyType();
    	task.Body.BodyType1 = BodyTypeType.Text;
    	task.Body.Value = string.Format("{0} {1}", DateTime.Now, taskText);
    	task.StartDate = DateTime.Now;
    	task.StartDateSpecified = true;
    	task.ReminderIsSet = true;
    	task.ReminderIsSetSpecified = true;
    	task.ReminderDueBy = DateTime.Now.AddHours(1);
    	task.ReminderDueBySpecified = true;
    
    	// Create the request to make a new task item.
    	var 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 = txtEmail.Text;
    
    	TargetFolderIdType target = new TargetFolderIdType();
    	target.Item = defTasksFolder;
    	createItemRequest.SavedItemFolderId = target;
    
    	CreateItemResponseType createItemResponse = ews.CreateItem(createItemRequest);
    	ResponseMessageType[] rmta = createItemResponse.ResponseMessages.Items;
    	if (rmta != null)
    	{
    		foreach (var responseItem in rmta)
    		{
    			if (responseItem.ResponseCode != ResponseCodeType.NoError)
    				MessageBox.Show(string.Format("{0} {1}", responseItem.ResponseCode, responseItem.MessageText));
    		}
    		MessageBox.Show("done");
    	}
    	else
    		MessageBox.Show("no response found");
    
    }
    
    

     

    The problem is that for other user (B) this code doesn't work. Error

    ErrorFolderNotFound The specified folder could not be found in the store.
    


     

    is returned in the response. AFAIK it is because access to the EWS is being made with user A credentials and user B task folder should be modified.

    Is there any administrator role in the EWS ?

    Actually I'm not limited with EWS only. I've tried to send e-mail with ics vCalendar file attached but this e-mail have no Accept and Deny buttons - it looks like ordinary email. Also it creates calendar event and I need to create a new task.

    The only one limitation is that Microsoft Office Outlook is not installed on the computer were c# code will be executed, so it is not possible to use Outlook as COM server.

     

    Is there any way to create task for other user in the Exchange programatically?


    Regards
    Wednesday, January 11, 2012 4:29 PM

All replies