sending mail from an applet

I have a java applet that I would like to send
mail from. Can anybody tell me how I would
go about this?
afsacAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_ares_Commented:
Hi !

At first , you need the Mail & Activation Packages from Sun


import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import com.sun.mail.*;


And with this method you ca send the mail .
The Vector is used to report any error that occurs .



public static Vector sendMessage(String data,String adress) {
 Vector result = new Vector(10,1);
 String eMail = adress;

 try {
         Properties local_send_props = new Properties();

// the mail server
/ put the mailserver to the property file
  local_send_props.put("mail.smtp.host", "ns1.infonet-dev.co.jp");

// create a session
                        
Session session = Session.getDefaultInstance(local_send_props, null);

// create a message

  Message msg = new MimeMessage(session);

// set the recipient
            msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(eMail,false));

// the message subject
      msg.setSubject("System Information ");

// header
            msg.setHeader("YMailer","Controller");

//
msg.setFrom(new InternetAddress("Sorry-None"));

            msg.setDescription("This_is_a_System_Information");

// set the message text
msg.setText(data.toString());

// send the message

Transport.send(msg);

result.addElement(new Boolean("true"));
// simple error handling
}
catch (Exception e){
      System.err.println("Fehler: "+e);
      result.addElement(new Boolean("false"));
      result.addElement(e.toString());
}
return result;

thats all .

This should work with applications & applets .

have fun !

Roland
0
afsacAuthor Commented:
This looks exactly like what I'm looking for,
but where can I find:

Mail & Activation Packages from Sun

Thanx

Don
0
heyhey_Commented:
.. or you can implement SMTP protocol yourself (or find some free implementation on the web) ...
0
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

Ravindra76Commented:
I think it is better to implemnet SMTP
0
Ravindra76Commented:
I think it is better to implemnet SMTP
as heyhey told

0
afsacAuthor Commented:
my applet is running on a Sun Unix box
which has Netscapes Mail server running on it.
If I understand what you are saying about
SMTP, it is installed and running on my Unix
server. So if this is good, could someone
give me some example code as how to
send an Email message from within my
java applet code?
Thanx for all your help and input!
Don
0
heyhey_Commented:
0
afsacAuthor Commented:
heyhey,
     The link that you suggested that I look at was
exactly what I was looking for! It works like a charm.
I would like to award you the points, but how can I do that?
Don
0
afsacAuthor Commented:
heyhey,
     The link that you suggested that I look at was
exactly what I was looking for! It works like a charm.
I would like to award you the points, but how can I do that?
Don
0
heyhey_Commented:
you have to reject the current answer.
than you can accept my comemnt as answer (I think) or I will propose an answer :)

glad that you solved your problem :)
0
afsacAuthor Commented:
I am rejecting this answer because heyhey's solution worked
best for me.  Thanks to all who had input to my problem.
Don
0
afsacAuthor Commented:
Ok, set this up so that I can award you the points.
JGmail was the solution to my problem and all is
working well. THANKS!
0
heyhey_Commented:
Answer :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.