I made this generic static class which I can call from anywhere in my app. Of course you need the JavaMail library.
import java.util.Date; import java.util.Properties; import javax.mail.*; import javax.mail.internet.*; public class Send { private static final String smtpServer = "localhost"; private static final String smtpPort = "25"; private static final String smtpSender = "[EMAIL PROTECTED]"; public Send() { } public static String message(String to, String sub, String body) { try { Properties props = System.getProperties(); props.put("mail.smtp.host", smtpServer); props.put("mail.smtp.port", smtpPort); props.put("mail.from", smtpSender); Session session = Session.getDefaultInstance(props, null); Message msg = new MimeMessage(session); msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to)); msg.setFrom(InternetAddress.getLocalAddress(session)); msg.setSubject(sub); msg.setText(body); msg.setSentDate(new Date()); Transport.send(msg); } catch (Exception e) { System.err.println("ERROR: FOCUS: Send: sendmail error: " + e.getMessage()); return e.getMessage(); } return ""; } } HTH Murray On 23 Oct 2005 at 23:19, C.F. Scheidecker Antunes wrote: > Hello all, > > I need to email a simple text message from within an action. > > I've tried creating a class using javax.mail.* and javax.mail.internet.* > classes but without success. > > I wonder if there is any simple recipe for that. > > Thanks, > > C.F. > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.1.361 / Virus Database: 267.12.4/146 - Release Date: 21/10/2005 > FOCUS Computing Mob: 0415 24 26 24 [EMAIL PROTECTED] http://www.focus-computing.com.au -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.361 / Virus Database: 267.12.4/146 - Release Date: 21/10/2005 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]