aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes simple javamail example getting error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "simple javamail example getting error" Watch "simple javamail example getting error" New topic
Author

simple javamail example getting error

rajesh mara
Greenhorn

Joined: Nov 30, 2006
Posts: 11
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import javax.mail.Address.*;
import javax.mail.internet.InternetAddress;

public class SendApp {
public static void send(String smtpHost, int smtpPort,
String from, String to,
String subject, String content)
throws AddressException, MessagingException {
// Create a mail session
java.util.Properties props = new java.util.Properties();
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.port", ""+smtpPort);
Session session = Session.getDefaultInstance(props, null);

// Construct the message
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipient(Message.RecipientType.TO, new

InternetAddress(to));
msg.setSubject(subject);
msg.setText(content);

// Send the message
Transport.send(msg);
}

public static void main(String[] args) throws Exception {
// Send a test message
send("localhost", 2525, "company_pro@yahoo.com",

"vinay@hotmail.com",
"hi ", "How are you WithRegards Vinay"); }
}

I am getting error as

Exception in Thread "main" java.lang.NoClassDefFoundError: javax/mail/Address
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
Do you have the JavaMail jar file in your classpath?


Ping & DNS - updated with new look and Ping home screen widget
rajesh mara
Greenhorn

Joined: Nov 30, 2006
Posts: 11
ya i configured all the classpaths required for javamail to run
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
i configured all the classpaths required for javamail to run


Apparently not ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: simple javamail example getting error
 
Similar Threads
Need Help in creating a Java Mailer
Give me solution to send mail
Javamail error
Send Mail Error
NoClassDefFoundError JavaMail..........