title: converting List<Object> to string array and sending email to multiple address using java mail
body: <p>Hi I am trying to convert List to string array and sending multiple Attendees' email using java mail and it seemed to not work am I doing it right or not need advices here is the code thanks</p>
  
  <pre><code>    @PostMapping(path = "/createBooking/{location}")
      public ResponseEntity&lt;String&gt; create(@PathVariable(value = "location") String location,
              @Validated @RequestBody Booking book) {
          book.setStatus("reserved");
          book.setBookingCode(generatedString);
  
          bookingRepository.save(book);
  
          MimeMessage message = sender.createMimeMessage();
          MimeMessageHelper helper = new MimeMessageHelper(message);
          StringBuilder sb = new StringBuilder();
  
          try {
  
              String[] array = new String[book.getAtt().size()]; 
              int index = array.length;
              for (Object value : book.getAtt()) { 
                  array[index] = String.valueOf( value );
                  helper.setTo(array[index]);
              }
              sb.append("Agenda:" + " " + book.getBookingDesc()).append(System.lineSeparator());
              sb.append("When:" +  " " + book.getDateBooked() + " " + book.getStartTime() + " " + "To" + " " + book.getEndTime())
                      .append(System.lineSeparator());
              sb.append("Where:" + " " + location).append(System.lineSeparator());
              sb.append("By:" + " " + book.getBookedUser()).append(System.lineSeparator());
              sb.append("Booking code:" + " " + generatedString);
              helper.setText(sb.toString());
              helper.setSubject("Meeting");
          } catch (MessagingException e) {
              e.printStackTrace();
              return new ResponseEntity&lt;&gt;("Error while sending mail ..", HttpStatus.BAD_REQUEST);
          }
          sender.send(message);
  
          return new ResponseEntity&lt;&gt;("Inputs have been saved", HttpStatus.OK);
      }
  </code></pre>
  
  <p>here is the error that is shown in the email</p>
  
  <p><a href="https://i.stack.imgur.com/vRO2L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vRO2L.png" alt="enter image description here"></a></p>
  
  <p>here is the model classes</p>
  
  <p>Booking class</p>
  
  <pre><code>@Entity
  public class Booking implements Serializable{
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long bookingId;
  
      private String bookingDesc;
  
      private String bookedUser;
  
      private String bookedUserName;
  
      private String bookedEmail;
  
      private String bookingCode;
  
      @JsonFormat(pattern = "yyyy-MM-dd")
      private LocalDate dateBooked;
  
      @JsonFormat(pattern="HH:mm:ss", timezone = "GMT+8")
      private Time startTime;
  
      @JsonFormat(pattern="HH:mm:ss", timezone = "GMT+8")
      private Time endTime;
  
      private String status;
  
      @OneToMany(cascade = CascadeType.ALL)
      @JoinColumn(name = "booking_id")
      private List&lt;Attendees&gt; att = new ArrayList&lt;Attendees&gt;();
  
      @OneToOne(cascade = CascadeType.ALL)
      @JoinColumn(name = "room_booked")
      private Room room;
  // setters getters
  
  }
  </code></pre>
  
  <p>here is the Attendees class</p>
  
  <pre><code>@Entity
  @Table(name = "ref_attendees")
  public class Attendees implements Serializable{
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long idRefAttendees;
  
      private String attendeesEmail;
  
      @OneToOne(cascade = CascadeType.ALL)
      @JoinColumn(name = "trans_id")
      private Transaction tras;
  
      @ManyToOne(cascade = CascadeType.ALL)
      private Booking booking;
  //setters getters
  
  }
  </code></pre>
  
  <p>Here is how I pass data using postman</p>
  
  <p><a href="https://i.stack.imgur.com/YXUfr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YXUfr.png" alt="enter image description here"></a></p>
  
  <p>EDIT: I added the models that is related to the problem and added postman</p>