code: public static ObjectName createJavaMailObjectName(String serverName, String mailSessionID, int resourceCounter) {
          Hashtable<String, String> props = new Hashtable<String, String>();
          props.put(TYPE_SERVER, serverName);
          props.put(MAIL_SESSION_ID, mailSessionID);
          props.put(RESOURCE_ID, TYPE_JAVA_MAIL_RESOURCE + "-" + resourceCounter);
          ObjectName objectName;
          try {
              objectName = createObjectName(TYPE_JAVA_MAIL_RESOURCE, NAME_JAVA_MAIL_RESOURCE, props);
          } catch (IllegalArgumentException e) {
              // mailSessionID contains illegal characters
              props.remove(MAIL_SESSION_ID);
              objectName = createObjectName(TYPE_JAVA_MAIL_RESOURCE, NAME_JAVA_MAIL_RESOURCE, props);
          }
          return objectName;
      }
docs: Java mail factory methods ...