import java.io.*;
import java.util.*;

import org.jdesktop.jdic.desktop.*;

public class Mailer {
  public static void main(String[] args) throws Exception {
    if (args.length == 0) {
      System.out.println("java Mailer fichier");
      System.exit(1);
    }

    File file = new File(args[0]);
    if (file.exists()) {
      List attachments = new ArrayList(1);
      attachments.add(file.getAbsolutePath());
      List tos = new ArrayList(1);
      tos.add("Romain Guy <romain.guy@jext.org>");

      Message mail = new Message();
      mail.setAttachments(attachments);
      mail.setBody("Voici une pièce jointe.");
      mail.setSubject(file.getName());
      mail.setToAddrs(tos);

      Desktop.mail(mail);

      if (Desktop.isPrintable(file))
        Desktop.print(file);
    }
  }
}