本文整理匯總了Java中javax.mail.SendFailedException.getValidUnsentAddresses方法的典型用法代碼示例。如果您正苦於以下問題:Java SendFailedException.getValidUnsentAddresses方法的具體用法?Java SendFailedException.getValidUnsentAddresses怎麽用?Java SendFailedException.getValidUnsentAddresses使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.mail.SendFailedException
的用法示例。
在下文中一共展示了SendFailedException.getValidUnsentAddresses方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleMessagingException
import javax.mail.SendFailedException; //導入方法依賴的package包/類
private String handleMessagingException(Exception e) {
StringBuffer exmess = new StringBuffer();
do {
if (e instanceof SendFailedException) {
SendFailedException sfex = (SendFailedException)e;
Address[] invalid = sfex.getInvalidAddresses();
if (invalid != null) {
exmess.append("\n ** Invalid Addresses");
if (invalid != null) {
for (int i = 0; i < invalid.length; i++)
exmess.append(" " + invalid[i]);
}
}
Address[] validUnsent = sfex.getValidUnsentAddresses();
if (validUnsent != null) {
exmess.append("\n ** ValidUnsent Addresses");
if (validUnsent != null) {
for (int i = 0; i < validUnsent.length; i++)
exmess.append(" "+validUnsent[i]);
}
}
Address[] validSent = sfex.getValidSentAddresses();
if (validSent != null) {
exmess.append("\n ** ValidSent Addresses");
if (validSent != null) {
for (int i = 0; i < validSent.length; i++)
exmess.append(" "+validSent[i]);
}
}
}
if (e instanceof MessagingException)
e = ((MessagingException)e).getNextException();
else
e = null;
} while (e != null);
return exmess.toString();
}
示例2: handleEMailError
import javax.mail.SendFailedException; //導入方法依賴的package包/類
/**
* @param mex
*/
private static void handleEMailError(MessagingException mex) {
mex.printStackTrace();
System.out.println();
Exception ex = mex;
do {
if (ex instanceof SendFailedException) {
SendFailedException sfex = (SendFailedException) ex;
Address[] invalid = sfex.getInvalidAddresses();
if (invalid != null) {
System.out.println(" ** Invalid Addresses");
for (int i = 0; i < invalid.length; i++)
System.out.println(" " + invalid[i]);
}
Address[] validUnsent = sfex.getValidUnsentAddresses();
if (validUnsent != null) {
System.out.println(" ** ValidUnsent Addresses");
for (int i = 0; i < validUnsent.length; i++)
System.out.println(" " + validUnsent[i]);
}
Address[] validSent = sfex.getValidSentAddresses();
if (validSent != null) {
System.out.println(" ** ValidSent Addresses");
for (int i = 0; i < validSent.length; i++)
System.out.println(" " + validSent[i]);
}
}
System.out.println();
if (ex instanceof MessagingException)
ex = ((MessagingException) ex).getNextException();
else
ex = null;
} while (ex != null);
}
示例3: enviarPaginaEmails
import javax.mail.SendFailedException; //導入方法依賴的package包/類
/**
* Realiza el envio de un email paginado
* @param me
* @param envio
* @param destinatarios
* @param fechaInicio
* @return
*/
private static boolean enviarPaginaEmails(MensajeEmail me, Envio envio, List destinatarios, Date fechaInicio)
{
MobUtils utils = MobUtils.getInstance();
try {
EmailUtils emailUtils = EmailUtils.getInstance();
Date now = new Date();
if((now.getTime()-fechaInicio.getTime()) > utils.getLimiteTiempo().longValue()){
log.debug("Cancelamos envio por haberse superado el tiempo Maximo del proceso de envio");
return false;
}
if (simularEnvioEmail.booleanValue()){
log.debug("Email simulando envio");
Date inicioSimulacion = new Date();
while ( (inicioSimulacion.getTime() + (simularEnvioDuracion * 1000)) > System.currentTimeMillis() ){
// Esperamos tiempo simulacion
}
log.debug("Email envio simulado");
}else{
emailUtils.enviar(prefijoEnvioEmail, me,envio,destinatarios);
}
return true;
}catch (SendFailedException ex){
List invalidAddresses = null;
List unsentAddresses = null;
List validAddresses = null;
if(ex.getInvalidAddresses() != null){
invalidAddresses = new ArrayList();
for(int i=0;i<ex.getInvalidAddresses().length;i++){
invalidAddresses.add(ex.getInvalidAddresses()[i].toString());
}
}
if(ex.getValidUnsentAddresses() != null){
unsentAddresses = new ArrayList();
for(int i=0;i<ex.getValidUnsentAddresses().length;i++){
unsentAddresses.add(ex.getValidUnsentAddresses()[i].toString());
}
}
if(ex.getValidSentAddresses() != null){
validAddresses = new ArrayList();
for(int i=0;i<ex.getValidSentAddresses().length;i++){
validAddresses.add(ex.getValidSentAddresses()[i].toString());
}
}
log.debug("Error generando correo para el envio: " + envio.getNombre(), ex);
me.setError("Error generando correo para el envio: " + envio.getNombre() + "." + ex.getMessage());
me.setError(me.getError()+ " ERROR EMAILS: ");
if(invalidAddresses != null){
me.setError(me.getError()+ "-no validos-" + invalidAddresses.toString());
}
if(unsentAddresses != null){
me.setError(me.getError()+ "-no enviados-" + unsentAddresses.toString());
}
me.setError(me.getError() + ": " + ex.getMessage()+ ".");
me.setDestinatariosValidos(validAddresses);
me.setEstado(ConstantesMobtratel.ESTADOENVIO_ERROR);
} catch (DelegateException de) {
log.debug("Error accediendo a la cuenta por defecto de EMAIL");
me.setError("Error accediendo a la cuenta por defecto de EMAIL");
me.setEstado(ConstantesMobtratel.ESTADOENVIO_ERROR);
} catch (Exception e) {
log.debug("Error generando correo para el envio: " + envio.getNombre());
me.setError("Error generando correo para el envio: " + envio.getNombre() + "." + e.getMessage());
me.setError(me.getError()+ "ERROR EMAILS: " + destinatarios.toString() + ": " + e.getMessage()+ ".");
me.setEstado(ConstantesMobtratel.ESTADOENVIO_ERROR);
}
return false;
}
示例4: handleException
import javax.mail.SendFailedException; //導入方法依賴的package包/類
private void handleException(MessagingException mex) {
LOG.error("\n--Exception handling in MailHelper.java", mex);
Exception ex = mex;
do {
if (ex instanceof SendFailedException) {
SendFailedException sfex = (SendFailedException) ex;
Address[] invalid = sfex.getInvalidAddresses();
if (invalid != null) {
LOG.error(" ** Invalid Addresses", ex);
if (invalid != null) {
for (int i = 0; i < invalid.length; i++) {
LOG.error(" " + invalid[i]);
}
}
}
Address[] validUnsent = sfex.getValidUnsentAddresses();
if (validUnsent != null) {
LOG.error(" ** ValidUnsent Addresses", ex);
if (validUnsent != null) {
for (int i = 0; i < validUnsent.length; i++) {
LOG.error(" " + validUnsent[i], ex);
}
}
}
Address[] validSent = sfex.getValidSentAddresses();
if (validSent != null) {
LOG.error(" ** ValidSent Addresses", ex);
if (validSent != null) {
for (int i = 0; i < validSent.length; i++) {
LOG.error(" " + validSent[i], ex);
}
}
}
}
if (ex instanceof MessagingException) {
ex = ((MessagingException) ex).getNextException();
} else {
ex = null;
}
} while (ex != null);
}
示例5: exceptionToLogString
import javax.mail.SendFailedException; //導入方法依賴的package包/類
/**
* Try to return a usefull logString created of the Exception which was
* given. Return null if nothing usefull could be done
*
* @param e
* The MessagingException to use
* @return logString
*/
private String exceptionToLogString(Exception e) {
if (e.getClass().getName().endsWith(".SMTPSendFailedException")) {
return "RemoteHost said: " + e.getMessage();
} else if (e instanceof SendFailedException) {
SendFailedException exception = (SendFailedException) e;
// No error
if (exception.getInvalidAddresses().length == 0 && exception.getValidUnsentAddresses().length == 0)
return null;
Exception ex;
StringBuilder sb = new StringBuilder();
boolean smtpExFound = false;
sb.append("RemoteHost said:");
if (e instanceof MessagingException)
while ((ex = ((MessagingException) e).getNextException()) != null && ex instanceof MessagingException) {
e = ex;
if (ex.getClass().getName().endsWith(".SMTPAddressFailedException")) {
try {
InternetAddress ia = (InternetAddress) invokeGetter(ex, "getAddress");
sb.append(" ( " + ia + " - [" + ex.getMessage().replaceAll("\\n", "") + "] )");
smtpExFound = true;
} catch (IllegalStateException ise) {
// Error invoking the getAddress method
} catch (ClassCastException cce) {
// The getAddress method returned something
// different than InternetAddress
}
}
}
if (!smtpExFound) {
boolean invalidAddr = false;
sb.append(" ( ");
if (exception.getInvalidAddresses().length > 0) {
sb.append(Arrays.toString(exception.getInvalidAddresses()));
invalidAddr = true;
}
if (exception.getValidUnsentAddresses().length > 0) {
if (invalidAddr == true)
sb.append(" ");
sb.append(Arrays.toString(exception.getValidUnsentAddresses()));
}
sb.append(" - [");
sb.append(exception.getMessage().replaceAll("\\n", ""));
sb.append("] )");
}
return sb.toString();
}
return null;
}