Handling tasks on exchange


#1

Hi,


I want to process tasks on exchange. Does Aspose.Email supports this functionality like add/update/delete task on exchange programatically?

Regards

Cornelius

#2

Hi Cornelius,


Thanks for writing to Aspose.Email support team.

Aspose.Email supports processing tasks on exchange. You may use ExchangeTask class for handling task objects. You can also use different properties exposed by ExchangeTask like Subject, Status, DueDate, Priority etc. to configure the task on axchange.

Similarly ExchangeWebServiceClient provides functions like CreateTask, UpdateTask and DeleteTask. Please refer to the following sample code which demonstrate the required features.


public static void exchangeCreateTasks()
{
var credentials = new NetworkCredential(“username”, “123456”);
ExchangeWebServiceClient client = new ExchangeWebServiceClient(“https://exchangexyz/ews/exchange.asmx”, credentials);
            ExchangeTask task = new ExchangeTask();
task.Subject = “New-Test”;
task.Status = ExchangeTaskStatus.InProgress;
client.CreateTask(client.MailboxInfo.TasksUri, task);
client.UpdateTask(task);
task.Status = ExchangeTaskStatus.Completed;
client.UpdateTask(task);
client.DeleteTask(task.UniqueUri, DeleteTaskOptions.DeletePermanently);
}
public static void exchangeUpdateTasks()
{
var credentials = new NetworkCredential(“username”, “12345”);
ExchangeWebServiceClient client = new ExchangeWebServiceClient(“https://exchangexyz/ews/exchange.asmx, credentials);
ExchangeMessageInfoCollection tasks = client.ListMessages(client.MailboxInfo.TasksUri);
foreach (ExchangeMessageInfo info in tasks)
{
ExchangeTask task = client.FetchTask(info.UniqueUri);
task.Status = ExchangeTaskStatus.NotStarted;
task.DueDate = new DateTime(2012, 9, 26);
task.Priority = MailPriority.Low;
client.UpdateTask(task);
}
}
public static void exchangeDeleteTasks()
{
var credentials = new NetworkCredential(“username”, “1233456”);
ExchangeWebServiceClient client = new ExchangeWebServiceClient(“https://exchangexyz/ews/exchange.asmx, credentials);
ExchangeMessageInfoCollection tasks = client.ListMessages(client.MailboxInfo.TasksUri);
foreach (ExchangeMessageInfo info in tasks)
{
ExchangeTask task = client.FetchTask(info.UniqueUri);
if (task.Subject.Equals(“test”))
{
client.DeleteTask(task.UniqueUri, DeleteTaskOptions.DeletePermanently);
}
}
}

Please feel free to write us back if you have any other query in this regard.

#3

Hi team,
I am using Aspose.email 19.4 for java, while extracting “Tasks” from exchange server, It throws an exception : Exception in thread “main” java.lang.NullPointerException
at com.aspose.email.ayy.h(SourceFile:288)
at com.aspose.email.ayy.c(SourceFile:147)
at com.aspose.email.on.d(SourceFile:519)
at com.aspose.email.on.listTasks(SourceFile:475)
at com.aspose.email.on.listTasks(SourceFile:407)
at cs.main(cs.java:58)
however, there are 3 task in it.

TaskCollection taskCollection = client.listTasks();

	int iTasksCount = taskCollection.size();
	System.out.println(iTasksCount);
	for (int i = 0; i < iTasksCount; i++) {
	    ExchangeTask task = (ExchangeTask) taskCollection.get_Item(i);
	    System.out.println(task.getTimezoneId());
	    System.out.println(task.getSubject());
	    System.out.println(task.getStartDate());
	    System.out.println(task.getDueDate());
	}

#4

@pradeepnegi,

Can you please try to use Aspose.Email latest version 19.5 on your end and if there is still an issue than please share source files along with complete working sample project to reproduce issue on our end.


#5

I have tried Aspose.Email latest version 19.5 but the result is same. it still giving same exception.


#6

@pradeepnegi,

As requested earlier can you please share source file along with complete sample code so that we may further investigate to help you out.


#7

I can’t share account credentials with you, can you check on your own on a sample hotmail account.


#8

@pradeepnegi,

I have observed your comments and like to share that there is generally no issue while extracting tasks from email account using IMapClient. Please provide a sample test account along with a working code representing which Client you are using to fetch email or tasks on your end. Please share the requested information so that we may proceed further to help you.


#9

I am extracting tasks from Exchange web services,
This is the code i am using for extracting Tasks from hotmail account.
IEWSClient client = EWSClient.getEWSClient(“https://outlook.office365.com/ews/exchange.asmx”, "@hotmail.com", “”, “”);

	ExchangeMessageInfoCollection msgInfoColl = client.listMessages(client.getMailboxInfo().getTasksUri());
	System.out.println(msgInfoColl.size());
	int i=0;
	for(ExchangeMessageInfo msg :msgInfoColl)
	{
		try
		{
			i++;
			System.out.println(msg.getMessageInfoType());
			if(msg.getMessageInfoType()==MessageInfoType.Task)
			{
				System.out.println(msg.getSubject());
				ExchangeTask task = client.fetchTask(msg.getUniqueUri());
				System.out.println(task.getUniqueId());
				System.out.println(task.getSubject());
				System.out.println(task.getStartDate());
				System.out.println(task.getDueDate());
			}
		}
		catch(Exception ep)
		{
			ep.printStackTrace();
		}
	}

#10

@pradeepnegi,

I have worked with the sample account shared by you and have been able to observe the issue. An issue with ID EMAILJAVA-34548 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

For security reason, I have removed the credentials from your above code in this thread. However, we will be using them in our investigation of issue and request you to please don’t change the credentials till the issue gets resolved.