// Collection of code snippets by Arne VajhÃ¸j 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.util.*;

import javax.mail.*;
import javax.mail.internet.*;

public class Email2 {
   private final static String SMTP_SERVER = "192.168.1.10";
   private final static String FROM = "arne@vajhoej.dk";
   public static void send(String to, String subj, String body) {
      try {
         Properties props = System.getProperties();
         props.put("mail.smtp.host", SMTP_SERVER);
         Session session = Session.getDefaultInstance(props, null);
         MimeMessage message = new MimeMessage(session);
         message.setFrom(new InternetAddress(FROM));
         message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
         message.setSubject(subj, "ISO-8859-1");
         message.setText(body, "ISO-8859-1");
         Transport.send(message);
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
   public static void main(String[] args) {
      send("arne_v@mail.danbbs.dk", "Test 2 med ÆØÅ", "ABC\n123\nÆØÅ\n");
   }
}
