Update of /cvsroot/rssmailer/dailystrips-mailer/src/be/tomk/dailystripsmailer
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1981/src/be/tomk/dailystripsmailer
Added Files:
Mailer.java
Log Message:
--- NEW FILE: Mailer.java ---
package be.tomk.dailystripsmailer;
import java.io.File;
import java.io.FileFilter;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.mail.MessagingException;
import javax.mail.internet.AddressException;
import be.tomk.toolkit.mail.MailSender;
public class Mailer {
public static void main(String[] args) throws MalformedURLException, AddressException, MessagingException {
String workdir = "C:/dailystrips-1.0.28/work";
final String today = new SimpleDateFormat("yyyy.MM.dd").format(new Date());
File work = new File(workdir);
File[] dirs = work.listFiles(new DirectoryFilter());
FileFilter fileFilter = new FileFilter() {
public boolean accept(File pathname) {
return pathname.getName().startsWith(today);
}
};
Set<URL> urls = new HashSet<URL>();
for (int i = 0; i<dirs.length; i++) {
File current = dirs[i];
File[] todaysFiles = current.listFiles(fileFilter);
for (int j = 0; j < todaysFiles.length; j++) {
urls.add(todaysFiles[j].toURL());
}
}
URL[] attachments = urls.toArray(new URL[urls.size()]);
MailSender.send("uit.pandora.be", "dai...@to...", new String[]{"dai...@to..."}, "Dailystrips for "+today, "", true, attachments);
}
private static class DirectoryFilter implements FileFilter {
public boolean accept(File pathname) {
return pathname.isDirectory();
}
}
}
|