Example usage for org.apache.commons.mail Email setSubject

List of usage examples for org.apache.commons.mail Email setSubject

Introduction

In this page you can find the example usage for org.apache.commons.mail Email setSubject.

Prototype

public Email setSubject(final String aSubject) 

Source Link

Document

Set the email subject.

Usage

From source file:com.cm.util.SendEmail.java

public static void main(String args[]) {
    try {// w ww  .  j a  va  2s.com
        Email email = new Email();
        email.setEmailAddress("lawale4me@yahoo.com");
        email.setSubject("Your have create a new Case :");
        email.setMessage("Case Body" + "\n " + Log.APPURL);
        System.out.println("about to send");
        new SendEmail().sendSimpleMail(email);
        System.out.println("sent");
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.bytecode.util.SendEmail.java

public static void main(String args[]) {
    try {//from w  w w.j ava  2  s.c o  m
        Email email = new Email();
        email.setEmailAddress("lawale4me@yahoo.com");
        email.setSubject("Your have create a new Case :");
        email.setMessage("Case Body" + "\n");
        System.out.println("about to send");
        new SendEmail().sendSimpleMail(email);
        System.out.println("sent");
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.aprodher.actions.util.EmailUtils.java

public static void enviaEmail(Mensaje mensagem) throws EmailException {
    Email email = new SimpleEmail();
    email = conectaEmail();//from  w w  w  . j av a2 s.co  m
    email.setSubject(mensagem.getTitulo());
    email.setMsg(mensagem.getMensagem());
    email.addTo(mensagem.getDestino());
    String resposta = email.send();
    JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("emailenviado") + resposta);
}

From source file:gsn.utils.services.EmailService.java

/**
 * This method cover most of the cases of sending a simple text email. If the email to be sent has to be configured
 * in a way which is not possible whith the parameters provided (such as html email, or email with attachement, ..),
 * please use the {@link #sendCustomEmail(org.apache.commons.mail.Email)} method and refer the API
 * {@see http://commons.apache.org/email/}.
 *
 * @param to      A set of destination email address of the email. Must contain at least one address.
 * @param object  The subject of the email.
 * @param message The msg of the email.// w  w  w  . j a  va2s  .c o  m
 * @return true if the email has been sent successfully, false otherwise.
 */
public static boolean sendEmail(ArrayList<String> to, String object, String message) {
    Email email = new SimpleEmail();
    try {
        email.setSubject(object);
        email.setMsg(message);
        if (to != null)
            for (String _to : to)
                email.addTo(_to);
        sendCustomEmail(email);
        return true;
    } catch (EmailException e) {
        logger.warn(
                "Please, make sure that the SMTP server configuration is correct in the file: " + SMTP_FILE);
        logger.error(e.getMessage(), e);
        return false;
    }
}

From source file:de.alpharogroup.message.system.service.CommonsEmailSendService.java

public static void sendEmail(final EmailConfiguration config, InfoMessageModel model) throws EmailException {
    // TODO make class for email config...
    Email email = new SimpleEmail();
    email.setHostName(config.getHostName());
    email.setSmtpPort(config.getSmtpPort());
    email.setFrom(model.getApplicationSenderAddress());
    email.setSubject(model.getMessageContentModel().getSubject());
    email.setMsg(model.getMessageContentModel().getContent());
    email.addTo(model.getRecipientEmailContact());
    email.send();/*from  w w w.  j  a va  2s  . c om*/
}

From source file:io.jhonesdeveloper.swing.util.EmailUtil.java

public static void sendBasicText(String hostName, String username, String password, String from, String subject,
        String msg, String[] to) throws EmailException {
    Email email = new SimpleEmail();
    email.setHostName(hostName);/*from   w  w  w.java 2 s  . c o  m*/
    email.setSmtpPort(465);
    email.setAuthenticator(new DefaultAuthenticator(username, password));
    email.setSSLOnConnect(true);
    email.setFrom(from);
    email.setSubject(subject);
    email.setMsg(msg);
    email.addTo(to);
    email.send();
}

From source file:br.fgv.util.EmailSender.java

public static void enviarEmail(String body, String subject) throws EmailException {

    StringBuffer sb = new StringBuffer("");
    sb.append(body);//  w w w  .  j ava 2  s  .co  m

    Email email = new SimpleEmail();
    email.setHostName("smtp.gmail.com");

    email.setDebug(true);
    email.setSSLOnConnect(true);

    email.addTo("wesley.seidel@gmail.com");

    email.setAuthentication("wseidel.fgv", "batavinhofgv");

    email.setFrom("wseidel.fgv@gmail.com");
    email.setSubject(subject);
    email.setMsg(sb.toString());

    email.send();
}

From source file:at.tugraz.kmi.medokyservice.ErrorLogNotifier.java

public static void errorEmail(String msg) {

    Email email = new SimpleEmail();
    email.setHostName("something.com");
    email.setSmtpPort(465);/*from w w w.  j ava 2s  . c o m*/
    DefaultAuthenticator auth = new DefaultAuthenticator("username", "pwd");
    email.setAuthenticator(auth);
    email.setSSLOnConnect(true);
    try {
        email.setFrom("email address");
        email.setSubject("[MEDoKyService] Error");
        email.setMsg(msg);
        email.addTo("yourmail.com");
        email.send();
    } catch (EmailException e) {
        e.printStackTrace();
    }

}

From source file:com.reizes.shiva.net.mail.EmailSender.java

public static String sendMail(String host, int port, String from, String to, String subject, String text)
        throws IOException, EmailException {

    if (to != null && host != null) {
        String[] emailTo = StringUtils.split(to, ';');

        Email email = new SimpleEmail();
        email.setHostName(host);/*ww  w.java  2  s  .c  o m*/
        email.setSmtpPort(port);
        email.setFrom(from);

        for (String recv : emailTo) {
            email.addTo(recv);
        }

        email.setSubject(subject);
        email.setMsg(text);
        return email.send();
    }

    return null;
}

From source file:connection.EmailSending.java

public static void sendTextEmail(String subject, String content, String recipientEmail) {
    Email email = new SimpleEmail();

    email.setHostName(MailInfor.HOST_NAME);
    email.setSmtpPort(465);//from  w  w w.  j  a va 2s.c  om
    email.setAuthenticator(new DefaultAuthenticator(MailInfor.EMAIL_SENDER, MailInfor.PASSWORD));
    email.setSSLOnConnect(true);

    try {
        email.setFrom(MailInfor.EMAIL_SENDER);
        email.setSubject(subject);
        email.setMsg(content);
        email.addTo(recipientEmail);

        email.send();
    } catch (EmailException ex) {
        Logger.getLogger(EmailSending.class.getName()).log(Level.SEVERE, null, ex);
    }
}