Link to home
Start Free TrialLog in
Avatar of spetrowitsch
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.pumpOneEventForHierarchy
Avatar of Gibu George
Gibu George
Flag of India image

Can you paste the entire exception stack trace?
Avatar of spetrowitsch
spetrowitsch

ASKER

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: javax/activation/DataSource
      at mail.MailSender.<init>(MailSender.java:26)
      at mail.MainFrame.actionPerformed(MainFrame.java:71)
      at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
      at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
      at java.awt.Component.processMouseEvent(Unknown Source)
      at javax.swing.JComponent.processMouseEvent(Unknown Source)
      at java.awt.Component.processEvent(Unknown Source)
      at java.awt.Container.processEvent(Unknown Source)
      at java.awt.Component.dispatchEventImpl(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Window.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)
ASKER CERTIFIED SOLUTION
Avatar of Gibu George
Gibu George
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mayank S
In case of Eclipse, to the build-path of the project you are running by Properties -> Java Build Path -> Add External JARs
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.SMTPSendFailedException: 550 5.7.0 Need to authenticate via SMTP-AUTH-Login {mp038}

      at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
      at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
      at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.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.RecipientType.TO,
                        InternetAddress.parse(to, false));
                  msg.setSentDate(new Date());
                  msg.setSubject(
                MimeUtility.encodeText(subject,"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");
            }
      }