sem.setAttachment(sb.toString());
StringBuffer sb = new StringBuffer(); char[] s = screen.getScreenAsChars(); int c = screen.getCols(); int l = screen.getRows() * c; int col = 0; for (int x = 0; x < l; x++, col++) { sb.append(s[x]); if (col == c) { sb.append('\n'); col = 0; } }
   public SendEMailDialog(Frame parent, Session session ) {      if (!isEMailAvailable()) {         JOptionPane.showMessageDialog(parent,                                       LangTool.getString("messages.noEmailAPI"),                                       "Error",                                       JOptionPane.ERROR_MESSAGE,null);      }      else {         this.session = session;         Screen5250 screen = session.getScreen();         Object[]      message = new Object[1];         message[0] = setupMailPanel("tn5250j.txt");         String[] options = new String[3];         int result = 0;         while (result == 0 || result == 2) {            // setup the dialog options            setOptions(options);            result = JOptionPane.showOptionDialog(                parent,                            // the parent that the dialog blocks                message,                           // the dialog message array                LangTool.getString("em.title"),    // the title of the dialog window                JOptionPane.DEFAULT_OPTION,        // option type                JOptionPane.QUESTION_MESSAGE,      // message type                null,                              // optional icon, use null to use the default icon                options,                           // options string array, will be made into buttons//                options[0]                         // option that should be made into a default button            );            switch(result) {               case 0: // Send it                  SendEMail sem = new SendEMail();                  sem.setConfigFile("SMTPProperties.cfg");                  sem.setTo((String)toAddress.getSelectedItem());                  sem.setSubject(subject.getText());                  if (bodyText.getText().length() >0)                     sem.setMessage(bodyText.getText());                  if (attachmentName.getText().length() > 0)                     sem.setAttachmentName(attachmentName.getText());                  StringBuffer sb = new StringBuffer();                  char[] s = screen.getScreenAsChars();                  int c = screen.getCols();                  int l = screen.getRows() * c;                  int col = 0;                  for (int x = 0; x < l; x++,col++) {                     sb.append(s[x]);                     if (col == c) {                        sb.append('\n');                        col = 0;                     }                  }                  sem.setAttachment(sb.toString());                  // send the information                  sendIt(parent,sem);                  sem.release();                  sem = null;                  break;               case 1: // Cancel      //		      System.out.println("Cancel");                  break;               case 2: // Configure SMTP                  configureSMTP(parent);      //		      System.out.println("Cancel");                  break;               default:                  break;            }         }      }   }