4 Replies Latest reply: Apr 19, 2012 6:31 PM by 931076 RSS

    sending emails in batch

    931076
      Hello,

      I am sending emails in batch such as:


      try

      transport.connect();

      loop count <= batchsize()
      try{
      transport.sendMessage(msg, msg.getAllRecipients());
      }
      catch(MessagingException mex){
      System.out.println('could not send particular email'); // i am writting this to logs

      }

      endloop;


      catch(MessagingException ex){

      ex.printstackRace();

      }

      finally{
      transport.close();
      }




      I want to know that catching exception when some particular email is not sent in the batch,is correct way of doing it above code?
      I am not able to reproduce such exception.Any idea? I mean how to track if any particular email is not sent?

      I tried giving bad receiver email address(non-existing) but it did not throw any exception,just sent notification email in sender's inbox that email is undeliverable.
      I also tried giving non-existing sender email address,but no luck to get exception.

      Thanks...