I think there is problem with the attachments,
I am sending the files inline
________________________________VELOCITYHTMLEMAIL.JAVA______________________________________________________
// Source File Name: VelocityHtmlEmail.java
package org.apache.turbine.util.velocity;
import java.net.URL;
import java.util.Hashtable;
import javax.mail.MessagingException;
import org.apache.turbine.services.velocity.TurbineVelocity;
import org.apache.turbine.util.Log;
import org.apache.turbine.util.RunData;
import org.apache.turbine.util.mail.HtmlEmail;
import org.apache.turbine.util.mail.MultiPartEmail;
import org.apache.turbine.util.template.TemplateInfo;
import org.apache.velocity.context.Context;
public class VelocityHtmlEmail extends HtmlEmail
{
public VelocityHtmlEmail setHtmlTemplate(String template)
{
htmlTemplate = template;
return this;
}
public VelocityHtmlEmail setTextTemplate(String template)
{
textTemplate = template;
return this;
}
public void send()
throws MessagingException
{
Context context = this.context;
context.put("mail", this);
String htmlbody = "";
String textbody = "";
try
{
if(htmlTemplate != null)
{
htmlbody = TurbineVelocity.handleRequest(context, htmlTemplate);
setHtmlMsg(htmlbody);
}
if(textTemplate != null)
{
textbody = TurbineVelocity.handleRequest(context, textTemplate);
setTextMsg(textbody);
}
}
catch(Exception e)
{
throw new MessagingException("Cannot parse template", e);
}
System.out.println ("RAKESH -------->the html body is " + htmlbody);
super.send();
}
public String embed(String surl, String name)
throws MessagingException
{
String cid = "";
try
{
URL url = new URL(surl);
cid = super.embed(url, name);
embmap.put(name, cid);
}
catch(Exception e)
{
Log.error("cannot embed " + surl + ": ", e);
}
return cid;
}
public String getCid(String filename)
{
String cid = (String)embmap.get(filename);
return "cid:" + cid;
}
private static final Context getContext(RunData data)
{
Context vc =
(Context)data.getTemplateInfo().getTemplateContext("VELOCITY_CONTEXT");
if(vc == null)
{
vc = TurbineVelocity.getContext(data);
data.getTemplateInfo().setTemplateContext("VELOCITY_CONTEXT", vc);
}
return vc;
}
public VelocityHtmlEmail(RunData data)
throws MessagingException
{
htmlTemplate = null;
textTemplate = null;
this.data = null;
embmap = null;
super.init();
this.data = data;
embmap = new Hashtable();
}
public VelocityHtmlEmail()
throws MessagingException
{
htmlTemplate = null;
textTemplate = null;
embmap = null;
super.init();
embmap = new Hashtable();
}
public void setContext(Context context)
{
this.context = context;
System.out.println("RAKESH -------->After setting the context" ) ;
}
private String htmlTemplate;
private String textTemplate;
private RunData data;
private Hashtable embmap;
private Context context;
}
_______________________________________________________________________________________________________________
________________________________KIWIEMAIL.JAVA________________________________________________________________
import org.apache.turbine.services.resources.TurbineResources;
import org.apache.turbine.util.mail.Email;
import org.apache.turbine.util.velocity.VelocityHtmlEmail;
import org.apache.velocity.context.Context;
public class KiwiEmail extends VelocityHtmlEmail
{
public KiwiEmail()
throws Exception
{
}
public static void sendEmail(Context context, String template, String toName,
String toEmail, String subject)
throws Exception
{
mail = new KiwiEmail();
mail.setContext(context);
mail.setFrom(TurbineResources.getString("mail.from.address"),
TurbineResources.getString("mail.from.name"));
mail.addTo(toEmail, toName);
mail.setSubject(subject);
mail.setHtmlTemplate(template);
mail.send();
}
static KiwiEmail mail = null;
}
_______________________________________________________________________________________________________________
----- Original Message -----
From: Rakesh Chauhan
To: Turbine Users List
Sent: Thursday, April 03, 2003 6:05 PM
Subject: Re: Help in use of VelocityHtmlEmails in Scheduled Jobs
Hi ,
I am using the turbine 2.2 released version. In one of the previous email thread
someone has mentioned that VelocityHtml is now changed and the changes commited in the
CVS .The changed class was suppose to support the a constructor which only takes a
Context. But it was not available in the 2.2 version so I had to migrate my own
modified VelocityHtmlEmail class from 2.1 to 2.2 . But after the migration I am
getting blank emails.
I am attaching the modified VelocityHtmlEmail class and the class that I call from
my scheduled jobs .
Thanks,
/rakesh
----- Original Message -----
From: Quinton McCombs
To: 'Turbine Users List'
Sent: Wednesday, April 02, 2003 8:01 PM
Subject: RE: Help in use of VelocityHtmlEmails in Scheduled Jobs
Even the released version of 2.2 would be better.
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, April 02, 2003 6:09 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Help in use of VelocityHtmlEmails in Scheduled Jobs
>
>
> Rakesh,
>
> I don't think your attachments came through. Also, have you
> tried 2.3 HEAD. There was some more refactoring to support
> commons-email.
>
> Eric
>
> -----Original Message-----
> From: Rakesh Chauhan [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, April 02, 2003 3:37 AM
> To: Turbine Users List
> Subject: Re: Help in use of VelocityHtmlEmails in Scheduled Jobs
>
>
> I am attaching the changed VelocityHtmlEmail and the class
> which I use to send the Emails from my application and a
> sample template. Thanks, /rakesh
>
> ----- Original Message -----
> From: Fabio Daprile <mailto:[EMAIL PROTECTED]>
> To: Turbine Users List <mailto:[EMAIL PROTECTED]>
> Sent: Wednesday, April 02, 2003 12:42 PM
> Subject: Re: Help in use of VelocityHtmlEmails in Scheduled Jobs
>
> Hello,
>
> i've got some similar problems when migrating from 2.1 to
> 2.2, but i'll
> need your code to better understand
> your problem.
>
> greetings.
>
> Fabio Daprile
>
> Rakesh Chauhan wrote:
>
> >Hi ,
> > I am trying to use VelocityHtmlEmail from my scheduled jobs.I
> >changed
> the VelocityHtmlEmail to include a constructor which takes a
> Context as parameter. When I did the same changes in turbine
> 2.1 I was getting the HTML emails, but now I have moved to
> turbine2,2-rc2 and I get blank emails. Can anybody tell me
> why is this happening, I have debugged till HtmlEmail and I
> can see the message properly formatted and available there ,
> only thing is I am getting blank Emails.
> >Thanks,
> >/rakesh
> >
> >
> >
>
> --
> ************************************
> W�rth Phoenix S.r.l.
> Fabio Daprile
>
> Via Kravogl 4
> I-39100 Bolzano
> Phone: +39 0471 564111 (direct 564066)
> Fax: +39 0471 564122
> mailto:[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
> http:// www.wuerth-phoenix.com <http://www.wuerth-phoenix.com>
> *************************************
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]