Project

General

Profile

« Previous | Next » 

Revision 2105

Implement sending email reports to harvest administrator and site administrator

View differences:

HarvestSiteSchedule.java
374 374
  
375 375

  
376 376
  /**
377
   * Sends a report to the site summarizing the results of the harvest
378
   * operation.
377
   * Sends a report to the site summarizing the results of the harvest at
378
   * that site.
379 379
   */
380 380
  void reportToSite() {
381 381
    PrintStream body;
382
    String from = "Metacat Harvester";
382
    String from = harvester.harvesterAdministrator;
383
    String maxCodeLevel = "info";
383 384
    MailMessage msg;
385
    int nErrors = 0;
384 386
    String subject = "Report from Metacat Harvester";
385 387
    String to = contactEmail;
386 388
    
387 389
    if (!to.equals("")) {
388 390
      System.out.println("Sending report to siteScheduleID=" + siteScheduleID +
389 391
                         " at address: " + contactEmail);
390
      
391 392
      try {
392
        msg = new MailMessage();
393
        msg = new MailMessage(harvester.smtpServer);
393 394
        msg.from(from);
394 395
        msg.to(to);
395 396
        msg.setSubject(subject);
396 397
        body = msg.getPrintStream();
397
        
398
        harvester.printHarvestLog(body, maxCodeLevel, siteScheduleID);
399
        msg.sendAndClose();        
398 400
      }
399 401
      catch (IOException e) {
400 402
        System.out.println("There was a problem sending email to " + to);
401 403
        System.out.println("IOException: " + e.getMessage());
402 404
      }
403
      
404 405
    }
405 406
  }
406 407
    

Also available in: Unified diff