Ejemplo n.º 1
0
  // Prefered way of how it should be used.
  public MailAgent(
      String to,
      String cc,
      String bcc,
      String from,
      String subject,
      String content,
      String smtpHost)
      throws FrameworkExecutionException {
    try {
      this.to = to;
      this.cc = cc;
      this.bcc = bcc;
      this.from = from;
      this.subject = subject;
      this.content = content;
      this.smtpHost = smtpHost;

      message = createMessage();
      message.setFrom(new InternetAddress(from));
      setToCcBccRecipients();

      message.setSentDate(new Date());
      message.setSubject(subject);
      message.setText(content);
    } catch (AddressException ex) {
      throw new FrameworkExecutionException(ex);
    } catch (MessagingException ex) {
      throw new FrameworkExecutionException(ex);
    } finally {

    }
  }
Ejemplo n.º 2
0
  public void collect(BufferedReader in, Message msg) throws MessagingException, IOException {

    String line;
    StringBuffer sb = new StringBuffer();
    while ((line = in.readLine()) != null) {
      sb.append(line);
      sb.append("\n");
    }

    // If the desired charset is known, you can use
    // setText(text, charset)
    msg.setText(sb.toString());
  }