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
Java

Avatar of undefined
Last Comment
spetrowitsch
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Mayank S
Mayank S
Flag of India image

In case of Eclipse, to the build-path of the project you are running by Properties -> Java Build Path -> Add External JARs
Avatar of spetrowitsch
spetrowitsch

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.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");
            }
      }
Java
Java

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.

102K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo