Question
After a console restart, I cant access to mail, i get "No Such Provider Exception"
Good day
I have robotic process, that uses the e mail to send notifications and retrieve information from the mail body or the attachments. Today by the morning, i am notified that the robotic process arent reading the mail.
i'm Using this dependency
com.sun.mail
javax.mail
1.6.2
I'm using this process:
public ArrayList getTodayNewEmails() //throws Exception
{
//EmailInfo toReturn = new EmailInfo();
local_server.info ("Obteniendo los correos nuevos de hoy...");
ArrayList messagesList = new ArrayList();
Properties props = System.getProperties();
props.put("mail.store.protocol", "imap");
props.put("mail.imap.auth.plain.disable", "true");
props.put("mail.imap.host", host);
props.put("mail.imap.port", ""+port);
props.put("mail.imap.ssl.enable", "true");
props.put("mail.imap.starttls.enable", "true");
props.put("mail.imap.auth", "true");
props.put("mail.imap.auth.mechanisms", "XOAUTH2");
props.put("mail.imap.user", username);//Mail Address
props.put("mail.imap.partialfetch","false");
props.put("mail.imap.fetchsize", "2097152");
props.put("mail.debug", "true");
props.put("mail.debug.auth", "true");
String token = getAuthTokenIMAP(tenant_id, client_id, client_secret_value);//tenantId, clientId, client_secret);
System.out.println("Token devuelto: "+token);
local_server.info("Token devuelto: "+token);
Session session = Session.getInstance(props);
local_server.info("Sesion obtenida por medio de autorizacion en dos pasos");//+this.password);//
try
{
Store store = session.getStore("IMAP");
local_server.info("Obtenemos el Store imap");
//local_server.info("Parametros. Usuario: "+this.username+" "+this.password+"\nHost: "+this.host+" port: "+this.port);
store.connect(host, username, token);
local_server.info("Se conectó al Store");
Folder inbox = store.getFolder("INBOX");
local_server.info("Obteniendo los mensajes no leÃ%ADdos del folder Inbox y que sean de hoy...");
inbox.open(Folder.READ_WRITE);
Message[] messages = inbox.search(
new FlagTerm(new Flags(Flags.Flag.SEEN), false));
//inbox.close(false);
// Sort messages from recent to oldest
/*
Arrays.sort( messages, (m1, m2 ) ->
{
try
{
return m2.getSentDate().compareTo( m1.getSentDate() );
}
catch (MessagingException e )
{
throw new RuntimeException( e );
}
} );
*/
for ( Message message : messages )
{
DateFormat sdf = new SimpleDateFormat("yyyyMMdd");
//local_server.info("Fecha Mensaje: "+sdf.format(message.getSentDate()));
//local_server.info("Fecha Hoy: "+sdf.format(new Date()));
if (sdf.format(message.getSentDate()).equals(sdf.format(new Date())))
{
messagesList.add(message);
}
}
//local_server.info("Mensajes no leÃ%ADdos hoy: " + messagesList.size());
//inbox.close(false);
}
catch (NoSuchProviderException e)
{
local_server.info("No such provider exception");
local_server.error(e.getMessage());
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
local_server.error(sw.toString());
}
catch (MessagingException e)
{
local_server.info("MessagingException conectando al store");
local_server.error(e.getMessage());
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
local_server.error(sw.toString());
}
return messagesList;
}
Everything was ok untim March 28th at 6 o clock, when I get an advice from a console restart
after that I getting the "No such Provider Exception" From one moment to another, i don't change my code.
I need help to resolve this issue please!:
