1 Reply Latest reply: Aug 12, 2013 1:29 PM by Bshannon-Oracle RSS

    Unable to send mail to distribution list using java

    915089

      Hi,

      Need help in solving the below issue.

       

      We are having an application, which need to send an email to a distribution list (which contains 10 users).

      But it is not sending any email and not showing any error or exception.

       

      The sample code goes here:

       

        public static void main(String args[]) {

             Session session = Session.getDefaultInstance(fMailServerConfig, null);
             MimeMessage message = new MimeMessage(session);
             String htmlBody = "checking notification";
             String subject = "Notification";
             try {

                InternetAddress[] addressTo = new InternetAddress[1];

               addressTo[0] = new InternetAddress(abc.xyz@company.com); // distribution list is abc.xyz@company.com

               message.setRecipients(Message.RecipientType.BCC, addressTo);

              Multipart mp = new MimeMultipart();
              MimeBodyPart htmlPart = new MimeBodyPart();
              htmlPart.setContent(htmlBody, "text/html");
              mp.addBodyPart(htmlPart);
              message.setSubject(subject);
              message.setContent(mp);
               Transport.send(message);
             } catch (MessagingException ex) {
                   System.err.println("Cannot send email. " + ex);

             }
      }

       

      can anone help me with what wrong am i doing here?

      any solution could be a great help!

       

      Thanks

      Swathi