Methods Summary |
---|
public static void | main(java.lang.String[] args)
if (args.length != 3) {
System.err.println("Usage: BatchMail subj template custlist");
System.exit(1);
}
BatchMailer b = new BatchMailer();
String subj = args[0];
String template = args[1];
String listfile = args[2];
b.readTemplate(template);
b.setSubject(subj);
b.readCustList(listfile);
b.sendMails();
|
public void | readCustList(java.lang.String fileName)Read the customer list.
Format: one customer email per line.
BufferedReader is = new BufferedReader(new FileReader(fileName));
String line;
while ((line = is.readLine()) != null) {
custList.add(line);
}
is.close();
|
public void | readTemplate(java.lang.String fileName)Read the template file.
messageBody = null;
BufferedReader is = new BufferedReader(new FileReader(fileName));
String line;
StringBuffer bs = new StringBuffer();
while ((line = is.readLine()) != null) {
bs.append(line).append("\n");
}
messageBody = bs.toString();
is.close();
|
public void | sendMails()
Iterator it = custList.iterator();
while (it.hasNext()) {
String customer = (String)it.next();
try {
// This should be a bit more flexible :-(
Mailer.send("mailhost",
customer, "ian@darwinsys.com", subject, messageBody);
System.out.println(customer + " HANDOFF OK");
} catch (MessagingException e) {
System.out.println(customer + " failed: " + e.toString());
}
}
|
public void | setSubject(java.lang.String s)
subject = s;
|