public static void updateARule() {
    IEWSClient client = getAsposeEWSClient();
    System.out.println("Connected to Exchange server");

    // Get all Inbox Rules
    InboxRule[] inboxRules = client.getInboxRules();

    // Loop through each rule
    for (InboxRule inboxRule : inboxRules) {
      // Display name of the rule
      System.out.println("Display Name: " + inboxRule.getDisplayName());
      if (inboxRule.getDisplayName() == "Message from client ABC") {
        System.out.println("Updating the rule....");

        // Add a new condition. From address
        inboxRule
            .getConditions()
            .getFromAddresses()
            .set_Item(0, new MailAddress("*****@*****.**", true));
        client.updateInboxRule(inboxRule);
      }
    }
  }
  public static void readRules() {
    IEWSClient client = getAsposeEWSClient();
    System.out.println("Connected to Exchange server");

    // Get all Inbox Rules
    InboxRule[] inboxRules = client.getInboxRules();

    // Display information about each rule
    for (InboxRule inboxRule : inboxRules) {
      // Display name of the rule
      System.out.println("Display Name: " + inboxRule.getDisplayName());

      // Conditions included in this rule
      System.out.println("Conditions: ");

      // Check if there is a "From Address" condition
      if (inboxRule.getConditions().getFromAddresses().size() > 0) {
        for (MailAddress fromAddress : inboxRule.getConditions().getFromAddresses()) {
          System.out.println(
              "From: " + fromAddress.getDisplayName() + " - " + fromAddress.getAddress());
        }
      }

      // Check if there is a "Subject Contains" condition
      if (inboxRule.getConditions().containsSubjectStrings().size() > 0) {
        for (String subject : inboxRule.getConditions().containsSubjectStrings()) {
          System.out.println("Subject contains: " + subject);
        }
      }

      // Actions included in this rule
      System.out.println("Actions: ");

      // Check if there is a "Move to Folder" action
      if (inboxRule.getActions().getMoveToFolder().length() > 0) {
        System.out.println("Move message to folder: " + inboxRule.getActions().getMoveToFolder());
      }
    }
  }