Ok. The subject: render a JSP/Freemaker/Velocity file in a Struts Action, to
send an email. I mean, the "problem" is getting the HTML email body from an
Action. The action skeleton would be:

public void sendEmail extends ActionSupport {

     private String username;

     public String execute() {
         // Validate parameters;
         ....
         // Send email
         Email mail = new Email();
         email.setFrom("[EMAIL PROTECTED]");
         email.setTo("[EMAIL PROTECTED]");
         email.setSubject("welcome");
         email.setBody(*this.renderJSP()*);
         Mailer.send(email);

         // Response to user.
         return ActionSupport.SUCCESS;
     }
}

The problem is "renderJSP" method, so it constructs a customized JSP with
username data. For example, "renderJSP" should return something like:

<html>
  <body>
     <p>Welcome [EMAIL PROTECTED]</p>
     <p>this is a welcome email.</p>
  </body>
</html>

The object is render this email inside the user request. For me, it's not
important the template engine (JSP, FreeMaker, Velocity); the main thing is
getting it run from an Action.

Thanks again for your help and patience.

Esteve
2008/6/23 Dave Newton <[EMAIL PROTECTED]>:

> --- On Mon, 6/23/08, Esteve Camps Chust <[EMAIL PROTECTED]> wrote:
> > May you help me once again and guide me on the code? I've been
> > trying to do what you said me, but I cann't get it run.
>
> What specifically are you having issues with? If it's FreeMarker issues you
> might have better luck on a more appropriate FreeMarker list/forum. It's
> pretty straight-forward, though.
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to