Sending MIME Email

String html =
											"<html><head><title>Java Mail</title></head>" +
											"<body>Some HTML content.</body></html>";
											Multipart mp = new MimeMultipart();
											BodyPart textPart = new MimeBodyPart( );
											textPart.setText("This is the message body.");
											BodyPart htmlPart = new MimeBodyPart( );
											htmlPart.setContent(html, "text/html");
											mp.addBodyPart(textPart);
											mp.addBodyPart(htmlPart);
											msg.setContent(mp);
											Transport.send(msg);

MIME stands for Multimedia Internet Mail Extensions. MIME is supported by all major email clients and is the standard way of including attachments to messages. MIME allows you to attach a variety of media types, such as images, video, and .pdf files to an email message. The JavaMail API also supports MIME messages, and it is nearly ...

Get Java™ Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.