// Collection of code snippets by Arne Vajhøj // posted to eksperten.dk, usenet and other places (2002-now) import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; public class SendMultipartEmail { public static void main(String[] args) { sendMultipartEmail(); } public static void sendMultipartEmail() { try { Properties props = System.getProperties(); props.put("mail.smtp.host", "192.168.1.10"); Session session = Session.getDefaultInstance(props, null); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress("nn@somewhere.dk")); message.addRecipient(Message.RecipientType.TO, new InternetAddress("nn@somewhere.dk")); message.setSubject("Test"); MimeBodyPart mpart1 = new MimeBodyPart(); mpart1.setText("Linie 1\n" + "Linie 2"); MimeBodyPart mpart2 = new MimeBodyPart(); mpart2.setContent("