Java Email Send sendBulkUpdateFailureNotice(final String msgBody)

Here you can find the source of sendBulkUpdateFailureNotice(final String msgBody)

Description

send Bulk Update Failure Notice

License

Open Source License

Declaration

public static boolean sendBulkUpdateFailureNotice(final String msgBody) 

Method Source Code

//package com.java2s;
/*/*from  ww  w.  j a  v a 2 s . co m*/
 * Copyright (c) 2013 IANA. All Rights Reserved. THE AUTHOR MAKES NO
 * REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE
 * AUTHOR SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT
 * OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */

import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;

import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class Main {
    private static Properties emailProps = new Properties();

    public static boolean sendBulkUpdateFailureNotice(final String msgBody) {

        Session session = Session.getInstance(emailProps,
                new javax.mail.Authenticator() {
                    @Override
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication("", "");
                    }
                });
        try {
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress("admin@dver.intermodal.org"));
            message.addRecipients(Message.RecipientType.TO,
                    new InternetAddress[] { new InternetAddress(
                            "admin@dver.intermodal.org") });
            message.setSubject("Bulk DVER Update via XLS failure notice:");
            message.setText(msgBody);
            message.setContent(msgBody, "text/html");
            Transport.send(message);
            return true;
        } catch (MessagingException e) {
            e.getMessage();
            return false;
        }
    }
}

Related

  1. getMailSender(MimeMessage message)
  2. getSenderEmail(MimeMessage msg)
  3. send(final String username, final String password, final String toEmail, final String subject, final String content)
  4. send(String from, String to, String bcc, String subject, String content)
  5. send(String to, String from, String subject, String text, Properties mailProps)
  6. sendEmail(final String aFromEmailAddr, final String aToEmailAddr, final String aSubject, final String aBody)
  7. sendEmail(Session session, String fromEmail, String toEmail, String subject, String body)
  8. sendEmail(String subject, String text, String receiverEmail)
  9. sendEmail(String to, String from, String subject, String text)