public static String newName(Mail mail) throws MessagingException {
  String oldName=mail.getName();
  if (oldName.length() > 76) {
    int count=0;
    int index=0;
    while ((index=oldName.indexOf('!',index + 1)) >= 0) {
      count++;
    }
    if (count > 7) {
      throw new MessagingException("Unable to create a new message name: too long." + " Possible loop in config.xml.");
    }
 else {
      oldName=oldName.substring(0,76);
    }
  }
  return oldName + "-!" + random.nextInt(1048576);
}

public static String newName ( Mail mail ) throws MessagingException { String oldName = mail . getName ( ) ; if ( oldName . length ( ) > 76 ) { int count = 0 ; int index = 0 ; while ( ( index = oldName . indexOf ( '!' , index + 1 ) ) >= 0 ) { count ++ ; } if ( count > 7 ) { throw new MessagingException ( "Unable to create a new message name: too long." + " Possible loop in config.xml." ) ; } else { oldName = oldName . substring ( 0 , 76 ) ; } } return oldName + "-!" + random . nextInt ( 1048576 ) ; }
create a unique new primary key name for the given mailobject .
