How to create task to other users task folder in exchange server.

I was doing some task related to creating¬† task to other users task folder in exchange server. Tried with lots of way but fail, finally got a way by using “Microsoft Exchange Server 2010 Exchange Web Services “.

Basically what I did is, there will be a user in exchange server who will have the permission to impersonate other users in exchange server, then the user will impersonate a user and will create the task to the users task list. And the task will be available in the sercond user’s task list in outlook or any other email client.

The details about the excahnge web services are available in

The code of the task creation is given below :

Download exchange web service API from and add refference to the project.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Exchange.WebServices;
using Microsoft.Exchange.WebServices.Data;
using Microsoft.Exchange.Data;
using System.IO;

private static ExchangeService GetExchangeService()
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationMethod;

ExchangeService oService = new ExchangeService();

#region Using Auto discover url

//oService.Credentials = new WebCredentials(“mainUser”, “Pass@123”, “domain”);

#endregion Using Auto discover url
#region Using exchange URL
oService.Credentials =¬† new WebCredentials(“mainUser”, “Pass@123”, “domain”);

oService.Url = new Uri(“”);
#endregion Using exchange URL

return oService;

private void CreateTask() ////Main method
ExchangeService oService = GetExchangeService();

Task oTask = new Task(oService);
oService.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, “”);

oTask.ActualWork = 10;

oTask.Body = txtBody.Text;

oTask.Importance = Importance.High;
oTask.StartDate =  DateTime.Today;
oTask.Status = TaskStatus.InProgress;
oTask.Subject = txtSubject.Text;
Recurrence.WeeklyPattern weeklyPattern = new Recurrence.WeeklyPattern(DateTime.Today, 2, new DayOfTheWeek[] { DayOfTheWeek.Saturday, DayOfTheWeek.Wednesday });
oTask.Recurrence = weeklyPattern;
oTask.IsReminderSet = true;
oTask.ReminderDueBy = new DateTime(2010, 12, 5, 11, 05, 05);
oTask.PercentComplete = 11.10;
oTask.Attachments.AddFileAttachment(“TestAttachment”, File.ReadAllBytes(@”C:\temp.txt”));

StringList lstCategory = new StringList();
lstCategory.Add( “RED Category”);

lstCategory.Add( “BLACK Category”);
lstCategory.Add(“BLUE Category”);
oTask.Categories = lstCategory;


private static bool CertificateValidationMethod(

object sender,

X509Certificate certificate,

X509Chain chain,

SslPolicyErrors sslPolicyErrors)

// If the certificate is a valid, signed certificate, return true.

if (sslPolicyErrors == System.Net.Security.SslPolicyErrors.None)

return true;

// If there are errors in the certificate chain, look at each error to determine the cause.

if ((sslPolicyErrors & System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors) != 0)

if (chain != null && chain.ChainStatus != null)

foreach (System.Security.Cryptography.X509Certificates.X509ChainStatus status in chain.ChainStatus)

if ((certificate.Subject == certificate.Issuer) &&
(status.Status == System.Security.Cryptography.X509Certificates.


// Self-signed certificates with an untrusted root are valid.



if (status.Status != System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)

// If there are any other errors in the certificate chain, the certificate is invalid,

// so the method returns false.

return false;




// When processing reaches this line, the only errors in the certificate chain are

// untrusted root errors for self-signed certificates. These certificates are valid

// for default Exchange server installations, so return true.

return true;


// In all other cases, return false.

return false;