0
         String testHTMLContent = testhtml+productlogo;
         Message message = new MimeMessage(session);
         message.setFrom(new InternetAddress(usern));
         message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to));
         message.setRecipients(Message.RecipientType.CC,InternetAddress.parse(ccaddr));
         message.setSubject(sub);
         //message.setText(body);
         // setDebugMsg("Attempting to send...");
         Transport transport = session.getTransport("smtps");

         MimeMultipart mimeMultipart = new MimeMultipart();

         MimeBodyPart msgContent = new MimeBodyPart();
         msgContent.setContent(testcontent, "text/plain");
         mimeMultipart.addBodyPart(msgContent);


         MimeBodyPart query = new MimeBodyPart();
         query.setHeader("Content-Type", "text/plain");
         query.setContent(queryString, "text/plain");
         mimeMultipart.addBodyPart(query);

         MimeBodyPart htmlPart = new MimeBodyPart();
         htmlPart.setHeader("Content-Type", "text/html");
         htmlPart.setContent(testHTMLContent,"text/html");
         mimeMultipart.addBodyPart(htmlPart);

         attachedfile="filepath/attach.docx";
         if(attachedfile.length()!=0){
         MimeBodyPart attachmentContent = new MimeBodyPart();
         DataSource source = new FileDataSource(attachedfile);
         attachmentContent.setDataHandler(new DataHandler(source));
         attachmentContent.setFileName(attachedfile);
         mimeMultipart.addBodyPart(attachmentContent);
         }


         message.setContent(mimeMultipart);

         transport.connect("smtp.gmail.com", 465, usern, pass);
         Transport.send(message);
         transport.close();



         The above code is sending the only the resolution as content and the second text 'query' as attachment(.txt) and html content as .htm attachment. Please coorect the code..Thanks..
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Hemanth.Satkuri
0

ehm... correct the code? would you first mind telling us what your problem is? you are saying what it does. so, what is it supposed to do?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.