Kalaimaan

Doing simple things to make great life

Posts Tagged ‘Java interface’

Delete Email item in Exchange Server EWS

Posted by kalaimaan on February 10, 2009

Delete Email Item In Exchange Server using Java Stub interface

The below code is use to delete the particular item of email

/**
*
* @param id
* @param key
* @return
*/
private String deleteMessageItem(String id, String key)
{
String status = “Error”;

DeleteItemType deleteItemType = DeleteItemType.Factory.newInstance();

NonEmptyArrayOfBaseItemIdsType arrayOfBaseItemIdsType = NonEmptyArrayOfBaseItemIdsType.Factory.newInstance();
ItemIdType[] itemIdType = new ItemIdType[1];
itemIdType[0] = ItemIdType.Factory.newInstance();
itemIdType[0].setId(id);
itemIdType[0].setChangeKey(key);
arrayOfBaseItemIdsType.setItemIdArray(itemIdType);
deleteItemType.setItemIds(arrayOfBaseItemIdsType);
deleteItemType.setDeleteType(DisposalType.HARD_DELETE);

DeleteItemDocument deleteItemDocument = DeleteItemDocument.Factory.newInstance();
deleteItemDocument.setDeleteItem(deleteItemType);

DeleteItemResponseDocument deleteItemResponseDocument = null;
try
{
deleteItemResponseDocument = exService.DeleteItem(deleteItemDocument, null, null, null, null);
}
catch (RemoteException e)
{
return status;
}

DeleteItemResponseType deleteItemResponseType = deleteItemResponseDocument.getDeleteItemResponse();

ResponseMessageType[] responseMessageType = deleteItemResponseType.getResponseMessages()
.getDeleteItemResponseMessageArray();

for (int i = 0; i < responseMessageType.length; i++)
{
if (responseMessageType[i].getResponseClass() == ResponseClassType.SUCCESS)
status= “Success”;
else if (responseMessageType[i].getResponseClass() == ResponseClassType.ERROR)
status= “Error”;
}

return status;
}

Posted in Exchange Server | Tagged: , , , , , | 1 Comment »