Mailing a document is a good example of using the URL class. Before you start, you must have your client connected to a mailer, such as sendmail.
Create a URL object.
Set a URLConnection object.
Create an OutputStream object from the URL object.
Write the mail. For example:
public static void sendIt() throws Execption{ System.getProperty("mail.host", "salsa.sybase.com"); URL url = new URL(mailto:"name@sybase.com"); URLConnection conn = url.openConnection(); PrintStream out = new PrintStream(conn.getOutputStream(), true); out.print ("From: kennys@sybase.com"+"\r\n"); out.print ("Subject: Works Great!"+"\r\n"); out.print ("Thanks for the example - it works great!"+"\r\n"); out.close(); System.out.printIn(“Messsage Sent”); }
Install the MailTo class for sending e-mail from within the database:
select MailTo.sendIt()
Message Sent!
A connection to a server is required for these actions.