Recently we came across a scenario in which I have to send mails on the click of a button. But it was without an interface. So I thought about working the same with an interface.
Activation.jar and Mail.jar are the jar files that we need to add. You can find these files under C:\Program Files\SAP\JDT\eclipse\plugins\com.tssap.ext.libs.j2ee_1.3\lib
The user interface can be developed by using any layouts. I have choosen GridLayout.
public void doProcessBeforeOutput() throws PageException {
Form myForm = this.getForm(); // get the form from DynPage // create your GUI here.... Label to=new Label("To :"); Label sub=new Label("Sub :"); InputField to_address=new InputField("to_address"); InputField subject=new InputField("subject");
GridLayout gd = new GridLayout(); gd.setId("grid"); gd.setCellSpacing(10); gd.setWidth("80%"); gd.setDebugMode(true);
Session s = Session.getInstance(p); s.setDebug(false);
MimeMessage m = new MimeMessage(s); InternetAddress fromAddress = new InternetAddress(user.getEmail()); InternetAddress toAddress = new InternetAddress(tostr);