• Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing First JavaMail program

 
Rajeev Asthana
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am going to write first program that would send mails to users on Lotus Notes.

Can someone give me a little help how to start with...Any sample code..article....

Any help is greatly appreciated...

Rajeev. :roll:
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your first step should be to download JavaMail. After you install the download you will find a directory named "demo" which contains sample programs. They should be pretty much all you need to get started.

If you want tutorials, here's a hint: if I want to find a tutorial about using X in Java, I type the words "java x tutorial" into an Internet search engine. Almost always produces links to those tutorials.
 
Rajeev Asthana
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

I downloaded. How to install it? Should I unzip contents into my Java directory?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no installer. Just unzip it and study the README.txt file. It explains what is in the package, and how to use it.
 
Rajeev Asthana
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

As per Readme file, I compiled msgsh'ow.java successfully, but when I' running it by executing "java msgshow -" or java -classpath . mshshow -", it gives me error:

Exception in thread "main" java.mail.NoClassDefFoundError: javax/mail/MessageException.

Please help me in resolving it.

Thanks in advance,
Rajeev.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're missing mail.jar in your classpath. The Readme explains how to set the classpath to include both mail.jar and .; if you use the "-classpath" setting, you need to add both as well.
 
Rajeev Asthana
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks...

Now I want to run the program to send a mail to Hotmail.

Please tell me what should be put in 'put' statement...

Thanks in advance
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what you mean by the "'put' statement...". Can you explain?

Also: you can only connect to a mail server that allows SMTP connections. You will need to check with Hotmail that they allow this, since a lot of web based email providers only allow access via HTTP.
 
Tomas Anderson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried sending to hotmail, but could not find a valid smtp server. I think you would have better luck sending to GMail (if possible), which has an smtp server of "smtp.gmail.com".

For more information on sending email with authentication (you will need to authenticate your GMail email) check out the code here.


--TBA
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:
Not sure what you mean by the "'put' statement...". Can you explain?
That's a reference to the crosspost in the Sun JavaMail forum, here:

http://forum.java.sun.com/thread.jspa?threadID=738659&tstart=0

Looks like Rajeev forgot that he didn't mention the call to "put" in this crosspost. It's reply 4 of 6 on that other thread if you want to check it out.
 
Chinna Karuppan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anybody tell me some free smtp server that I can use for testing emails...I tried SMTP.GMAIL.COM..CONNECTION TIMED OUT..
The FreeSMTP Server I download doesn't seem to work..
THnks
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chinna,

please do not hijack threads with unrelated questions; start a new thread instead. One free mail server written in Java is Apache James; it's not hard to install and use.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!