spetrowitsch
asked on
Sending e-mail: EventDispatchThread.pumpOneEventForHierarchy
Hi,
I wanted to send an e-mail by a java-program. When I start to generate the message:
Session mailSession = Session.getDefaultInstance (new Properties());
SMTPMessage msg = new SMTPMessage(mailSession);
in the second line my eclipse ends up in:
EventDispatchThread.pumpOn eEventForH ierarchy
I wanted to send an e-mail by a java-program. When I start to generate the message:
Session mailSession = Session.getDefaultInstance
SMTPMessage msg = new SMTPMessage(mailSession);
in the second line my eclipse ends up in:
EventDispatchThread.pumpOn
Can you paste the entire exception stack trace?
ASKER
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundE rror: javax/activation/DataSourc e
at mail.MailSender.<init>(Mai lSender.ja va:26)
at mail.MainFrame.actionPerfo rmed(MainF rame.java: 71)
at javax.swing.AbstractButton .fireActio nPerformed (Unknown Source)
at javax.swing.AbstractButton $Handler.a ctionPerfo rmed(Unkno wn Source)
at javax.swing.DefaultButtonM odel.fireA ctionPerfo rmed(Unkno wn Source)
at javax.swing.DefaultButtonM odel.setPr essed(Unkn own Source)
at javax.swing.plaf.basic.Bas icButtonLi stener.mou seReleased (Unknown Source)
at java.awt.Component.process MouseEvent (Unknown Source)
at javax.swing.JComponent.pro cessMouseE vent(Unkno wn Source)
at java.awt.Component.process Event(Unkn own Source)
at java.awt.Container.process Event(Unkn own Source)
at java.awt.Component.dispatc hEventImpl (Unknown Source)
at java.awt.Container.dispatc hEventImpl (Unknown Source)
at java.awt.Component.dispatc hEvent(Unk nown Source)
at java.awt.LightweightDispat cher.retar getMouseEv ent(Unknow n Source)
at java.awt.LightweightDispat cher.proce ssMouseEve nt(Unknown Source)
at java.awt.LightweightDispat cher.dispa tchEvent(U nknown Source)
at java.awt.Container.dispatc hEventImpl (Unknown Source)
at java.awt.Window.dispatchEv entImpl(Un known Source)
at java.awt.Component.dispatc hEvent(Unk nown Source)
at java.awt.EventQueue.dispat chEvent(Un known Source)
at java.awt.EventDispatchThre ad.pumpOne EventForHi erarchy(Un known Source)
at java.awt.EventDispatchThre ad.pumpEve ntsForHier archy(Unkn own Source)
at java.awt.EventDispatchThre ad.pumpEve nts(Unknow n Source)
at java.awt.EventDispatchThre ad.pumpEve nts(Unknow n Source)
at java.awt.EventDispatchThre ad.run(Unk nown Source)
at mail.MailSender.<init>(Mai
at mail.MainFrame.actionPerfo
at javax.swing.AbstractButton
at javax.swing.AbstractButton
at javax.swing.DefaultButtonM
at javax.swing.DefaultButtonM
at javax.swing.plaf.basic.Bas
at java.awt.Component.process
at javax.swing.JComponent.pro
at java.awt.Component.process
at java.awt.Container.process
at java.awt.Component.dispatc
at java.awt.Container.dispatc
at java.awt.Component.dispatc
at java.awt.LightweightDispat
at java.awt.LightweightDispat
at java.awt.LightweightDispat
at java.awt.Container.dispatc
at java.awt.Window.dispatchEv
at java.awt.Component.dispatc
at java.awt.EventQueue.dispat
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In case of Eclipse, to the build-path of the project you are running by Properties -> Java Build Path -> Add External JARs
ASKER
Thanks! I still have another question, maybe you can help me:
I tried to create and send my email with the following code, but get always the message:
Fehler in Methode sendMessage(): 550 5.7.0 Need to authenticate via SMTP-AUTH-Login {mp038}
com.sun.mail.smtp.SMTPSend FailedExce ption: 550 5.7.0 Need to authenticate via SMTP-AUTH-Login {mp038}
at com.sun.mail.smtp.SMTPTran sport.issu eSendComma nd(SMTPTra nsport.jav a:1388)
at com.sun.mail.smtp.SMTPTran sport.mail From(SMTPT ransport.j ava:959)
at com.sun.mail.smtp.SMTPTran sport.send Message(SM TPTranspor t.java:583 )
at javax.mail.Transport.send0 (Transport .java:169)
at javax.mail.Transport.send( Transport. java:98)
.....
Properties props = System.getProperties();
MyAuthenticator auth = new MyAuthenticator();
props.put("mail.smtp.host" , "mail.gmx.net");
// holt Referenz auf ein Session-Objekt
Session mailSession = Session.getDefaultInstance (props, auth);
msg = new MimeMessage(mailSession);
// erzeugt ein MimeMessage-Objekt
// Im folgenden werden die Absenderadresse, der direkte
// Empfänger, das Absendedatum, der Betreff kodiert in
// US-ASCII Zeichen und der Headereintrag "X-Mailer" gesetzt
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message. RecipientT ype.TO,
InternetAddress.parse(to, false));
msg.setSentDate(new Date());
msg.setSubject(
MimeUtility.encodeText(sub ject,"iso- 8859-1","Q "));
msg.setHeader("X-Mailer", "JavaMail");
// kein Anhang, Mailtext wird direkt der Mail hinzugefügt.
msg.setText(messageText, "iso-8859-1");
Transport.send(msg);
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication( ) {
return new PasswordAuthentication ("MyAdr@gmx.de", "myGmxPwd");
}
}
I tried to create and send my email with the following code, but get always the message:
Fehler in Methode sendMessage(): 550 5.7.0 Need to authenticate via SMTP-AUTH-Login {mp038}
com.sun.mail.smtp.SMTPSend
at com.sun.mail.smtp.SMTPTran
at com.sun.mail.smtp.SMTPTran
at com.sun.mail.smtp.SMTPTran
at javax.mail.Transport.send0
at javax.mail.Transport.send(
.....
Properties props = System.getProperties();
MyAuthenticator auth = new MyAuthenticator();
props.put("mail.smtp.host"
// holt Referenz auf ein Session-Objekt
Session mailSession = Session.getDefaultInstance
msg = new MimeMessage(mailSession);
// erzeugt ein MimeMessage-Objekt
// Im folgenden werden die Absenderadresse, der direkte
// Empfänger, das Absendedatum, der Betreff kodiert in
// US-ASCII Zeichen und der Headereintrag "X-Mailer" gesetzt
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.
InternetAddress.parse(to, false));
msg.setSentDate(new Date());
msg.setSubject(
MimeUtility.encodeText(sub
msg.setHeader("X-Mailer", "JavaMail");
// kein Anhang, Mailtext wird direkt der Mail hinzugefügt.
msg.setText(messageText, "iso-8859-1");
Transport.send(msg);
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication(
return new PasswordAuthentication ("MyAdr@gmx.de", "myGmxPwd");
}
}