JAVA-how to manually compose a MIME multipart message
- by Augusto Picciani
I need to compose manually a MIME multipart message. I don't need to use any library to doing it.
I'm trying this without success:
out.println("From:myemail@mydomain");
out.flush();
out.println("To:myemail@mydomain");
out.flush();
out.println("Date:Thu, 25 Nov 2011 01:00:50 +0100");
out.flush();
out.println("Subject:manual test 269");
out.flush();
out.println("MIME-version:1.0");
out.flush();
out.print("Content-Type: multipart/mixed; boundary=\"1234567\"\n\n");
out.println("--1234567");
out.flush();
out.println("Content-Type: text/plain; charset:utf-8");
out.flush();
out.print("Content-Transfer-Encoding: 7bit\n\n");
out.flush();
out.print("test message\n\n");
out.flush();
out.println("--1234567");
out.flush();
out.println("Content-Type: text/html; charset:utf-8");
out.flush();
out.print("Content-Transfer-Encoding: 7bit\n\n");
out.flush();
out.print("<p><strong>test message in html</strong></p>\n\n");
out.flush();
out.println("--1234567--");
out.flush();
out.print("\r\n.\r\n");
out.flush();
Problem is that my mail client see the headers (from,subject,date,ecc.) but it doesn't see the message body. If i try without multipart it works fine.
Maybe problem is in whitespaces character.