You don't need any extensions; Java 1.1 can do all the common URLs.
try this:
/**
send e-mail to current e-mail address;
*/
private static void sendEmail (String text) {
// missing address
if (email == null || email.length () < 1)
System.out.println ("No e-mail address specified for " + text) ;
else if (smtp == null || smtp.length () < 1)
System.out.println ("No smtp server address specified for " + text) ;
// try to send the mail
else System.out.println ("Send " + text + " to " + email + " via " + smtp) ;
try {
// establish a network connection for sending mail
URL u = new URL ("mailto:" + email) ;
URLConnection c = u.openConnection () ;
c.setDoInput (false) ;
c.setDoOutput (true) ;
System.out.println ("Sendmail connecting to " + email + " ...") ;
System.out.flush () ;
c.connect () ;
PrintWriter out =
new PrintWriter (new OutputStreamWriter (c.getOutputStream ())) ;
// set up the header
out.println ("From: <webserver@" +
InetAddress.getLocalHost ().getHostName () + ">") ;
out.println ("To: " + email) ;
out.println ("Subject: Alarm from web-server") ;
out.println () ;
// add the message and close the connection, to send it
out.println (text) ;
out.close () ;
System.out.println ("E-mail sent to " + email + " for " + text) ;
System.out.flush () ;
}
catch (Exception e) {
e.printStackTrace () ;
System.out.println ("e-mail address set to null string") ;
email = "" ;
}
}
}
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: 22 July 1999 15:06
> > To: [EMAIL PROTECTED]
> > Subject: Sending mail from an application (Pre-v2 JDK, Redhat 6.0)
> >
> >
> > Hey all,
> > How would one go about sending e-mail from an
> > application? I have
> > tried doing it via the Runtime.exec() method and running a
> > long drawn out
> > 'mail' command, but the system executes it too fast and it
> > ends up getting
> > garbled in the process. Any ideas?
> >
> > Thanks,
> > Abe
> >
> > Abe L. Getchell - Systems Engineer
> > System Support Services
> > Kentucky Department of Education
> > Voice 502-564-2020x225
> > E-mail [EMAIL PROTECTED]
> > Web http://www.kde.state.ky.us/
> >
> >
> > ----------------------------------------------------------------------
> > To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> > with a subject of "unsubscribe". Trouble? Contact
> > [EMAIL PROTECTED]
> >
>
> ___________________________________________________________________________
> This email is confidential and intended solely for the use of the
> individual to whom it is addressed. Any views or opinions presented are
> solely those of the author and do not necessarily represent those of
> Sema Group.
> If you are not the intended recipient, be advised that you have received this
> email in error and that any use, dissemination, forwarding, printing, or
> copying of this email is strictly prohibited.
>
> If you have received this email in error please notify the Sema Group
> Helpdesk by telephone on +44 (0) 121 627 5600.
> ___________________________________________________________________________
>
> ------------------------------------------------------------------------
>
> Part 1.2 Type: application/ms-tnef
> Encoding: base64
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]