@Override
        @SuppressWarnings("SleepWhileInLoop")

        public void run() {
            try {
                int countSent = 0;
                int countUnsent = 0;
                String from = null;
                String date = null;
                String body = null;
                for (int i = 0; i < selectedDocNames.size(); i++) {
                    WriteSMSToDocFile wsmstdf = new WriteSMSToDocFile();
                    jdre.getjLabelResendEmail().setText("<html>Reseding <em>" + i + "</em> of <em>" + selectedDocNames.size() + "</em>  unsent Message documents. Please wait..");
                    jdre.getjTextAreaResendEmails().append("Generating doc\t : " + selectedDocNames.get(i) + "\n");
                    wsmstdf.setDocument(selectedDocNames.get(i));
                    switch (emailCase) {
                        case 0: {
                            from = view.getjTableWhatsappMsgs().getValueAt(convertIntegers(resendUnSentDocs)[i], 1).toString();
                            date = view.getjTableWhatsappMsgs().getValueAt(convertIntegers(resendUnSentDocs)[i], 2).toString();
                            body = view.getjTableWhatsappMsgs().getValueAt(convertIntegers(resendUnSentDocs)[i], 3).toString();
                            break;
                        }
                        case 1: {
                            from = view.getjTableWhatsappMsgs().getValueAt(convertIntegers(resendUnSentDocs)[i], 1).toString();
                            date = view.getjTableWhatsappMsgs().getValueAt(convertIntegers(resendUnSentDocs)[i], 2).toString();
                            body = view.getjTableWhatsappMsgs().getValueAt(convertIntegers(resendUnSentDocs)[i], 3).toString();
                            break;
                        }
                        case 2: {
                            from = view.getjTableWhatsappMsgs().getValueAt(convertIntegers(resendSentDocs)[i], 1).toString();
                            date = view.getjTableWhatsappMsgs().getValueAt(convertIntegers(resendSentDocs)[i], 2).toString();
                            body = view.getjTableWhatsappMsgs().getValueAt(convertIntegers(resendSentDocs)[i], 3).toString();
                            break;
                        }
                        case 3: {
                            from = view.getjTableWhatsappMsgs().getValueAt(convertIntegers(resendMixedDocs)[i], 1).toString();
                            date = view.getjTableWhatsappMsgs().getValueAt(convertIntegers(resendMixedDocs)[i], 2).toString();
                            body = view.getjTableWhatsappMsgs().getValueAt(convertIntegers(resendMixedDocs)[i], 3).toString();
                            break;
                        }
                    }
                    wsmstdf.setParagraph(from, date, body);
                    wsmstdf.doWritting();
                    jdre.getjTextAreaResendEmails().append("Generating ok? \t : Generation successful.\n");
                    jdre.getjTextAreaResendEmails().append("ReEmailing doc \t : " + selectedDocNames.get(i) + "\n");
                    Email email = new Email("targetingInbox@targeting.com", "localhbbost", selectedDocNames.get(i));
                    if (email.sendEmail()) {
                        jdre.getjTextAreaResendEmails().append("ReEmailing ok? \t : Re-emailing successful.\n");
                        new DatabaseHandle().updateEmailStatus(selectedDocNames.get(i), 1);
                        jdre.getjTextAreaResendEmails().append("DB Updated ok? \t : Database update successful\n");
                        countSent++;
                    } else {
                        jdre.getjTextAreaResendEmails().append("ReEmailing ok? \t : Re-emailing Unsuccessful.\n");
                        countUnsent++;
                    }
                    if (Utils.deleteTempFile(selectedDocNames.get(i))) {
                        jdre.getjTextAreaResendEmails().append("Delete doc ok? \t : Deleting temp doc successful.\n");
                    }
                    jdre.getjTextAreaResendEmails().append("------------------------------------------------\n");
                    if (i == selectedDocNames.size() - 1) {
                        jdre.getjTextAreaResendEmails().append("Done resending emails."
                                + "\n---------------------------"
                                + "\n- Total sent \t : " + countSent + "\t-"
                                + "\n- Total failed \t : " + countUnsent + "\t-"
                                + "\n---------------------------");
                        jdre.getjLabelResendEmail().setIcon(new javax.swing.ImageIcon(getClass().getResource("/smsapp/resources/ok_16.png")));
                        jdre.getjLabelResendEmail().setText("Done resending " + countSent + " of " + selectedDocNames.size() + " SMS documents emails.");
                        jdre.getjButtonCancel().setText("Close");
//                        resetTable(dtm, view.getjTableWhatsappMsgs());
//                        getSMSMessages();
                    }

                    Thread.sleep(1000);
                }

            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }
        }