Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JWebServices for Exchange
>
Tutorial
> Get rules
The following example shows you how to display all exisiting inbox rules.
import com.independentsoft.exchange.GetRulesResponse; import com.independentsoft.exchange.RequestServerVersion; import com.independentsoft.exchange.Rule; import com.independentsoft.exchange.Service; import com.independentsoft.exchange.ServiceException; public class Example { public static void main(String[] args) { try { Service service = new Service("https://myserver/ews/Exchange.asmx", "username", "password"); service.setRequestServerVersion(RequestServerVersion.EXCHANGE_2010_SP1); GetRulesResponse response = service.getRules(); for (Rule rule : response.getRules()) { System.out.println("Id:" + rule.getId()); System.out.println("DisplayName:" + rule.getDisplayName()); if(rule.getActions() != null) { System.out.println("Actions"); System.out.println("AssignCategories count:" + rule.getActions().getAssignCategories().size()); System.out.println("CopyToFolder:" + rule.getActions().getCopyToFolder()); System.out.println("Delete:" + rule.getActions().getDelete()); System.out.println("ForwardAsAttachmentToRecipients count:" + rule.getActions().getForwardAsAttachmentToRecipients().size()); System.out.println("ForwardToRecipients count:" + rule.getActions().getForwardToRecipients().size()); System.out.println("MarkAsRead:" + rule.getActions().getMarkAsRead()); System.out.println("MarkImportance:" + rule.getActions().getMarkImportance()); System.out.println("MoveToFolder:" + rule.getActions().getMoveToFolder()); System.out.println("PermanentDelete:" + rule.getActions().getPermanentDelete()); System.out.println("RedirectToRecipients count:" + rule.getActions().getRedirectToRecipients().size()); System.out.println("SendSMSAlertToRecipients count:" + rule.getActions().getSendSMSAlertToRecipients().size()); System.out.println("ServerReplyWithMessage:" + rule.getActions().getServerReplyWithMessage()); System.out.println("StopProcessingRules:" + rule.getActions().getStopProcessingRules()); System.out.println("-----------------------------------------------------------------------"); } if (rule.getConditions() != null) { System.out.println("Conditions"); System.out.println("Categories count:" + rule.getConditions().getCategories().size()); System.out.println("ContainsBodyStrings count:" + rule.getConditions().getContainsBodyStrings().size()); System.out.println("ContainsHeaderStrings count:" + rule.getConditions().getContainsHeaderStrings().size()); System.out.println("ContainsRecipientStrings count:" + rule.getConditions().getContainsRecipientStrings().size()); System.out.println("ContainsSenderStrings count:" + rule.getConditions().getContainsSenderStrings().size()); System.out.println("ContainsSubjectOrBodyStrings count:" + rule.getConditions().getContainsSubjectOrBodyStrings().size()); System.out.println("ContainsSubjectStrings count:" + rule.getConditions().getContainsSubjectStrings().size()); System.out.println("FlaggedForAction:" + rule.getConditions().getFlaggedForAction()); System.out.println("FromAddresses count:" + rule.getConditions().getFromAddresses().size()); System.out.println("FromConnectedAccounts count:" + rule.getConditions().getFromConnectedAccounts().size()); System.out.println("HasAttachments:" + rule.getConditions().hasAttachments()); System.out.println("Importance:" + rule.getConditions().getImportance()); System.out.println("IsApprovalRequest:" + rule.getConditions().isApprovalRequest()); System.out.println("IsAutomaticForward:" + rule.getConditions().isAutomaticForward()); System.out.println("IsAutomaticReply:" + rule.getConditions().isAutomaticReply()); System.out.println("IsEncrypted:" + rule.getConditions().isEncrypted()); System.out.println("IsMeetingRequest:" + rule.getConditions().isMeetingRequest()); System.out.println("IsMeetingResponse:" + rule.getConditions().isMeetingResponse()); System.out.println("IsNDR:" + rule.getConditions().isNDR()); System.out.println("IsPermissionControlled:" + rule.getConditions().isPermissionControlled()); System.out.println("IsReadReceipt:" + rule.getConditions().isReadReceipt()); System.out.println("IsSigned:" + rule.getConditions().isSigned()); System.out.println("IsVoiceMail:" + rule.getConditions().isVoiceMail()); System.out.println("ItemClasses count:" + rule.getConditions().getItemClasses().size()); System.out.println("MessageClassifications count:" + rule.getConditions().getMessageClassifications().size()); System.out.println("NotSentToMe:" + rule.getConditions().getNotSentToMe()); System.out.println("Sensitivity:" + rule.getConditions().getSensitivity()); System.out.println("SentCcMe:" + rule.getConditions().getSentCcMe()); System.out.println("SentOnlyToMe:" + rule.getConditions().getSentOnlyToMe()); System.out.println("SentToAddresses count:" + rule.getConditions().getSentToAddresses().size()); System.out.println("SentToMe:" + rule.getConditions().getSentToMe()); System.out.println("SentToOrCcMe:" + rule.getConditions().getSentToOrCcMe()); System.out.println("WithinDateRange:" + rule.getConditions().getWithinDateRange()); System.out.println("WithinSizeRange:" + rule.getConditions().getWithinSizeRange()); System.out.println("-----------------------------------------------------------------------"); } } } catch (ServiceException e) { System.out.println(e.getMessage()); System.out.println(e.getXmlMessage()); e.printStackTrace(); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*