title: Unable to send html content with attachment using java mail api
body: <p>i want to send to send the html content along with an attachment. So how can it be sent in same mail ?</p>
  
  <p>Could someone guide  me. Thanks </p>
  
  <pre><code>try {  
  
  MimeMessage message = new MimeMessage(session);  
              message.setFrom(new InternetAddress(user));  
  
  
              message.addRecipient(Message.RecipientType.CC,new InternetAddress("username@abc.com"));
               MimeBodyPart messageBodyPart1 = new MimeBodyPart();  
              messageBodyPart1.setText(data, "text/html");
              MimeBodyPart messageBodyPart2 = new MimeBodyPart();  
              String filename = "Data.xlsx";//change accordingly  
              DataSource source = new FileDataSource(filename);  
              messageBodyPart2.setDataHandler(new DataHandler(source));  
              messageBodyPart2.setFileName(filename);
              Multipart multipart = new MimeMultipart();  
              multipart.addBodyPart(messageBodyPart1);  
              multipart.addBodyPart(messageBodyPart2);  
              message.setSubject("FOS Report");  
              message.setContent(multipart); 
  
      //send the message  
       Transport.send(message);  
  
       System.out.println("message sent successfully...");  
  
       }
   catch (MessagingException e) {
  e.printStackTrace();}
  </code></pre>