Bom Pessoal, eu quebrei minha cabeça aqui e consegui.
olhem como ficou.
public void Sendmail(String body, String subject) throws MessagingException
{
Message message = new MimeMessage(getSession());
message.addRecipient(RecipientType.TO, new InternetAddress("<EMAIL_PARA"));
message.addFrom(new InternetAddress[] { new InternetAddress(“EMAIL_DE”) });
message.setSubject(subject);
message.setContent(body, “text/plain”);
Transport.send(message);
}
private Session getSession() {
Authenticator authenticator = new Authenticator();
Properties properties = new Properties();
properties.setProperty(“mail.smtp.submitter”, authenticator.getPasswordAuthentication().getUserName());
properties.setProperty(“mail.smtp.auth”, “true”);
properties.setProperty(“mail.smtp.host”, “IP_SERVIDOR_EXCHANGE”);
properties.setProperty(“mail.smtp.port”, “PORTA_EMAIL”);
return Session.getInstance(properties, authenticator);
}
private class Authenticator extends javax.mail.Authenticator {
private PasswordAuthentication authentication;
public Authenticator() {
String username = “<USUARIO_DO_DOMINIO”;
String password = “<SENHA_USUARIO>”;
authentication = new PasswordAuthentication(username, password);
}
protected PasswordAuthentication getPasswordAuthentication() {
return authentication;
}
}
Simples configura essa Classe ai com os dados do IP do servidor com a porta que o servidor utiliza e o usuario e senha do Dominio de Rede.
Depois é só criar uma classe main e chamar essa classe de envio de email.
Aqui funcionou certinho.
Abraço