Examples of MailServiceException


Examples of es.devel.mail.exception.MailServiceException

    }

    @Override
    public void sendMail(Throwable cause) throws MailServiceException {
        if (cause == null) {
            throw new MailServiceException("La excepcion a enviar por correo es nula: " + cause);
        }

        StringBuilder html = new StringBuilder(cause.toString());
        html.append("<p>");
        html.append(System.getProperties().toString());
View Full Code Here

Examples of es.devel.mail.exception.MailServiceException

        sendMail(new String[]{SUPPORT_EMAIL_ADDRESS}, FROM_ADDRESS_DEFAULT_VALUE, "Sistema de notificacion de errores de devel", "Ha ocurrido una excepcion generica:", html.toString());
    }

    public void sendMail(MailMessage mailMessageArg) throws MailServiceException {
        if (mailMessageArg.getMessageToAddresses() == null || mailMessageArg.getMessageToAddresses().isEmpty()) {
            throw new MailServiceException("No se han especificado destinatarios");
        }

        String[] recipients = mailMessageArg.getMessageToAddresses().toArray(new String[mailMessageArg.getMessageToAddresses().size()]);
        try {
            sendMail(recipients, mailMessageArg.getSenderEmailAddress(), mailMessageArg.getSenderName(), mailMessageArg.getSubject(), mailMessageArg.getMessageText(), mailMessageArg.getAttachments());
        } catch (MailServiceException ex) {
            throw new MailServiceException(ex);
        }
    }
View Full Code Here

Examples of es.devel.mail.exception.MailServiceException

    }

    @Override
    public void sendMail(String[] messageToAddresses, String sender, String senderName, String messageSubject, String messageBody, Collection<File> attachMents) throws MailServiceException {
        if (messageToAddresses == null || messageToAddresses.length == 0) {
            throw new MailServiceException("No se han especificado destinatarios");
        }

        if (sender == null || sender.equals("")) {
            throw new MailServiceException("No se ha especificado direccion de respuesta");
        }

        if (senderName == null || senderName.equals("")) {
            throw new MailServiceException("No se ha especificado nombre de remitente");
        }

        MimeMessage message = this.sender.createMimeMessage();
        MimeMessageHelper helper;

        try {
            //INDICAMOS QUE EL MENSAJE ES UN MENSAJE MULTI-PARTE
            helper = new MimeMessageHelper(message, true);
        } catch (MessagingException e2) {
            throw new MailServiceException(e2);
        }

        try {
            helper.setTo(messageToAddresses);
            helper.setSubject(messageSubject);
            helper.setText(messageBody, true);//INDICAMOS QUE EL CUERPO DEL MENSAJE VA EN HTML
            helper.setSentDate(new Date());
            helper.setFrom(sender);
            helper.setReplyTo(sender);
            if (attachMents != null && attachMents.size() > 0) {
                for (File item : attachMents) {
                    helper.addAttachment(item.getName(), item);
                }
            }
        } catch (Exception ex) {
            throw new MailServiceException("Ha habido problemas con la pasarela de correo: " + ex.toString(), ex);
        }

        this.sender.send(message);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.