public void getreportsent() {
    int i = 0;

    TableRow tr1 = new TableRow(this);
    tr1.setId(100 + i);
    tr1.layout(2, 0, 0, 0);

    // Create a TextView to house the name of the province
    final TextView label2 = new TextView(this);

    label2.setId(300 + i);
    label2.setText("      ");
    label2.setTextColor(Color.BLACK);
    label2.setPadding(20, 0, 0, 0);
    tr1.setPadding(0, 1, 0, 1);

    tr1.addView(label2);

    // Create a TextView to house the name of the province
    final TextView labeltitle2 = new TextView(this);

    labeltitle2.setId(300 + i);
    labeltitle2.setText("Subject");
    labeltitle2.setTextColor(Color.BLACK);
    labeltitle2.setPadding(20, 0, 0, 0);
    tr1.setPadding(0, 1, 0, 1);

    tr1.addView(labeltitle2);

    /*// Create a TextView to house the name of the province
    final TextView labelsend2 = new TextView(this);


    labelsend2.setId(500+i);
    labelsend2.setText("From");
    labelsend2.setTextColor(Color.BLACK);

    tr1.addView(labelsend2);*/

    // Create a TextView to house the value of the after-tax income
    final TextView labelrec2 = new TextView(this);

    labelrec2.setId(400 + i);
    labelrec2.setText("To");
    labelrec2.setTextColor(Color.BLACK);
    labelrec2.setPadding(20, 0, 0, 0);
    tr1.setPadding(0, 1, 0, 1);

    tr1.addView(labelrec2);

    // Create a TextView to house the value of the after-tax income
    final TextView labeldt2 = new TextView(this);

    labeldt2.setId(600 + i);
    labeldt2.setText("Date");
    labeldt2.setTextColor(Color.BLACK);
    labeldt2.setPadding(20, 0, 0, 0);
    tr1.setPadding(0, 1, 0, 1);

    tr1.addView(labeldt2);

    // Add the TableRow to the TableLayout
    tbl3.addView(
        tr1, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    for (int i1 = 0; i1 < rec2.length; i1++) {

      try {
        TableRow tr = new TableRow(this);
        tr.setId(100 + i);
        tr.layout(2, 0, 0, 0);

        // Create a TextView to house the name of the province
        final CheckBox chk1 = new CheckBox(this);
        ;

        chk1.setId(200 + i);
        chk1.setText("");
        chk1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(chk1);

        // Create a TextView to house the name of the province
        final TextView labeltitle1 = new TextView(this);

        labeltitle1.setId(300 + i);
        labeltitle1.setText(title2[i1]);
        labeltitle1.setTextColor(Color.BLACK);
        labeltitle1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(labeltitle1);

        /*// Create a TextView to house the name of the province
        final TextView labelsend1 = new TextView(this);


        labelsend1.setId(500+i);
        labelsend1.setText(send2[i1]);
        labelsend1.setTextColor(Color.BLACK);

        tr.addView(labelsend1);*/

        // Create a TextView to house the value of the after-tax income
        final TextView labelrec1 = new TextView(this);

        labelrec1.setId(400 + i);
        labelrec1.setText("" + rec2[i1]);
        labelrec1.setTextColor(Color.BLACK);
        labelrec1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(labelrec1);

        int date1 = Integer.parseInt(dt2[i1]);

        Date date = new Date(date1 * 1000L);

        SimpleDateFormat postFormater = new SimpleDateFormat("dd-MM-yyyy");

        String newDateStr = postFormater.format(date);

        // Create a TextView to house the value of the after-tax income
        final TextView labeldt1 = new TextView(this);

        labeldt1.setId(600 + i);
        labeldt1.setText("" + newDateStr);
        labeldt1.setTextColor(Color.BLACK);
        labeldt1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(labeldt1);

        final TextView labelbody1 = new TextView(this);

        labelbody1.setId(700 + i);
        labelbody1.setText("" + body2[i1]);
        labelbody1.setTextColor(Color.BLACK);
        labelbody1.setVisibility(View.GONE);

        labelbody1.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);

        tr.addView(labelbody1);

        // Add the TableRow to the TableLayout
        tbl3.addView(
            tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        i++;

        labeltitle1.setOnClickListener(
            new TextView.OnClickListener() {

              public void onClick(View v) {

                myDialog1 = new Dialog(mailbox.this);
                myDialog1.setContentView(R.layout.showmail);
                myDialog1.setTitle("Sent Mails");
                myDialog1.setCancelable(true);

                TextView from = (TextView) myDialog1.findViewById(R.id.txtfrom);
                TextView date = (TextView) myDialog1.findViewById(R.id.txtdate);
                TextView to = (TextView) myDialog1.findViewById(R.id.txtto);
                TextView title = (TextView) myDialog1.findViewById(R.id.txttitle);
                EditText body = (EditText) myDialog1.findViewById(R.id.editto);
                Button button = (Button) myDialog1.findViewById(R.id.btnback);

                String rec1 = labelrec1.getText().toString();

                String date1 = labeldt1.getText().toString();

                // String send1=labelsend1.getText().toString();

                String title1 = labeltitle1.getText().toString();

                String body1 = labelbody1.getText().toString();
                button.setText("Back To Sent mails");

                // from.setText(send1);
                date.setText(date1);
                to.setText(rec1);
                title.setText(title1);
                body.setText(body1);

                button.setOnClickListener(
                    new OnClickListener() {
                      public void onClick(View v) {
                        myDialog1.dismiss();
                      }
                    });

                myDialog1.show();
              }
            });
      } catch (Exception e) {
        tv.setText(e.getMessage());
      }
    }
  }