peguei umtutorial ai do site e fiz o seguinte
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Date;
import java.util.Properties;
import javax.swing.JOptionPane;
public class Email extends javax.swing.JDialog {
/** Creates new form Form_Email */
public Email(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Email();
}
public void Email() {
Properties p = new Properties();
p.put("mail.host", "smtp.hotmail.com");
Session session = Session.getInstance(p, null);
MimeMessage msg = new MimeMessage(session);
try {
// "de" e "para"!!
msg.setFrom(new InternetAddress(from.getText()));
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to.getText()));
// nao esqueca da data!
// ou ira 31/12/1969 !!!
msg.setSentDate(new Date());
msg.setSubject(message.getText());
msg.setText(subject.getText());
// evniando mensagem (tentando)
Transport.send(msg);
JOptionPane.showMessageDialog(this, "Email Send",
"Message", JOptionPane.INFORMATION_MESSAGE);
}catch (AddressException e) {
JOptionPane.showMessageDialog(this, "Address not found",
"Message", JOptionPane.INFORMATION_MESSAGE);
System.out.print(e);
}catch (MessagingException e) {
System.out.print(e);
JOptionPane.showMessageDialog(this, "Message not found",
"Message", JOptionPane.INFORMATION_MESSAGE);
}
}
o erro q ocorre alguem ajuda ai
javax.mail.MessagingException: Unknown SMTP host: smtp.hotmail.com;
nested exception is:
java.net.UnknownHostException: smtp.hotmail.com
isso mesmo mas e o que eu coloco ali meu ???
Um SMTP Válido
saberias algum???
Fabio,
Pelo que sei o Hotmail nao funciona com POP3 / SMTP, ele funciona com HTTP.
[]´s