You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Sven Richter <sr...@gmx.net> on 2005/09/19 22:59:56 UTC

J1.6: How to generate a HTML-confirmation mail

Hello,

since no one seems to know a solution to my problem using VelocityEmail, 
maybe someone can tell me a way to generate a HTML-confirmation email 
from a velocity template using another class.

I know that there's a class VelocityHtmlEmail, but in that class I can't 
seem to pass the Context from the Java class to the template (there is 
no 'setContext()' in that class). Or maybe somebody can suggest me 
another class, that I could use (with a small example on how to use it).

Thanks a lot,
Sven.


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: J1.6: How to generate a HTML-confirmation mail

Posted by Tristan Lyons <tr...@gmail.com>.
The SpringFramework also makes it really easy to send plaintext, html text
and attachments,

MimeMessagePreparator mimeMessage = new MimeMessagePreparator()
{
public void prepare(MimeMessage mimeMessage) throws MessagingException
{
String plaintextBody = /* ...whatever ...*/
String htmlBody = /* ...whatever.. */
MimeMessageHelper mimeMsg = new MimeMessageHelper(mimeMessage,
true, "UTF-8");
mimeMsg.setFrom(message.getFromEmail());
mimeMsg.setTo("to@somebody");
mimeMsg.setSubject("subject");
mimeMsg.setText(plaintextBody, htmlBody);
}
};

JavaMailSender sender = /* ... your sender... */
sender.send(mimeMessage);

On 9/21/05, Henning P. Schmiedehausen <hp...@intermeta.de> wrote:
>
> Sven Richter <sr...@gmx.net> writes:
>
> >Maybe now somebody knows what I can do? I think that's a pretty standard
> >function for a Jetspeed portal.
>
> I've answered your question on velocity-user.
>
> Best regards
> Henning
>
>
> --
> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
> hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/
>
> RedHat Certified Engineer -- Jakarta Turbine Development -- hero for hire
> Linux, Java, perl, Solaris -- Consulting, Training, Development
>
> 4 - 8 - 15 - 16 - 23 - 42
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: J1.6: How to generate a HTML-confirmation mail

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
Sven Richter <sr...@gmx.net> writes:

>Maybe now somebody knows what I can do? I think that's a pretty standard 
>function for a Jetspeed portal.

I've answered your question on velocity-user.

	Best regards
		Henning


-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

		      4 - 8 - 15 - 16 - 23 - 42

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: J1.6: How to generate a HTML-confirmation mail

Posted by Sven Richter <sr...@gmx.net>.
Hello,

Well, maybe I should show you what I got so far. Currently I'm using the 
VelocityEmail class as follows:

VelocityEmail vemail = *new* VelocityEmail();
context.put("bestellung", oData);  // here I put the oData-object into 
the context of the user, so that I can use it and read the data from the 
database
context.put("email", vemail);
vemail.setTo("SvenRichter", "emailaddress"); //
vemail.setFrom("Recipient", "emailadress");
vemail.setSubject("Bestellung");
vemail.setContext(context);
vemail.setTemplate("portlets/html/email-confirm.vm");
vemail.send();

And it works just fine for text-messages. But I just can't set the 
content-type to "text/html". As a result the email-client is displaying 
the message as text, instead of html. That's why I tried the following 
using the VelocityHtmlEmail class:

/VelocityHtmlEmail vemail = new VelocityHtmlEmail(data);/ /
context.put("vmail", vemail);/ /
context.put("bestellung", oData);/ /
vemail.addTo("emailaddress", "Sven Richter"); //data.getUser().getEmail());/
/vemail.setFrom("Recipient", "emailaddress");/ /
vemail.setHtmlTemplate("portlets/html/email-productpurcase.vm");/ /
vemail.send();

/But that way I can't use 'vemail.setContext(context);'. Because of that 
I can't access the data from the database using '$bestellung' in the 
template, which makes the whole thing useless to me.

Maybe now somebody knows what I can do? I think that's a pretty standard 
function for a Jetspeed portal.

Thanks a lot,
Sven.

Sven Richter schrieb:

> Hello,
>
> since no one seems to know a solution to my problem using 
> VelocityEmail, maybe someone can tell me a way to generate a 
> HTML-confirmation email from a velocity template using another class.
>
> I know that there's a class VelocityHtmlEmail, but in that class I 
> can't seem to pass the Context from the Java class to the template 
> (there is no 'setContext()' in that class). Or maybe somebody can 
> suggest me another class, that I could use (with a small example on 
> how to use it).
>
> Thanks a lot,
> Sven.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org