Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

JavaMail

Posted on 2005-03-02
12
Medium Priority
?
487 Views
Last Modified: 2013-11-24
I am using J2EE.
Anyone can provide sample codes using JavaMail to send an email?


hongjun
0
Comment
Question by:hongjun
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 37

Accepted Solution

by:
zzynx earned 1000 total points
ID: 13440442
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13440474
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:Naeemg
ID: 13440829
0
 
LVL 33

Author Comment

by:hongjun
ID: 13442195
I got NoClassDefFoundError.
I am suspecting my classpath is incorrect for javamail.

hongjun
0
 
LVL 33

Author Comment

by:hongjun
ID: 13442233
BTW, I have included activation.jar and mail.jar but still not working.
I am using this code
http://www.javaworld.com/javaworld/jw-10-2001/jw-1026-javamail.html
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13442288
Which class is not being found? The mail ones or the main class? Have you checked the package declaration?
0
 
LVL 33

Author Comment

by:hongjun
ID: 13442320
Thanks I got it to work.
However, I do have some queries.

The code example shows that you just need to include a smtp server address. However, username and password are omitted. I would prefer to enter them. Can help?

hongjun
0
 
LVL 33

Author Comment

by:hongjun
ID: 13442462
How to set a classpath in NetBeans?
It doesn't seem to be able to compile using netbeans because of classpath problem.

hongjun
0
 
LVL 29

Assisted Solution

by:bloodredsun
bloodredsun earned 1000 total points
ID: 13442491
When you connect to the Transport you can pass a username and password:

Transport transport =   session.getTransport("smtp");
transport.connect( host, username, password);

and you may need to add this line to the properties section
props.put("mail.smtp.auth", "true");
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13442508
If it's anything like Eclipse, right click on the project and select Java/build Path/ add jars
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13447403
>> How to set a classpath in NetBeans?
In netBeans you have to mount a jar to make it "available"

Thanks for accepting
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses
Course of the Month13 days, 1 hour left to enroll

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question