How do I go about referencing data I have in a custom sql table in an Email template? Is this possible or must I send the template out myself in code?
Rick
Referencing custom data in email template
-
- Lieutenant (LT)
- Posts: 66
- Joined: Mon Jun 22, 2009 5:49 pm
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: Referencing custom data in email template
You can make new nVelocity objects, but that is pretty complicated and there isn't a whole lot of info out on nVelocity. There are some posts on AC wiki-http://wiki.ablecommerce.com/index.php/ ... city&go=Go
I have created new template parameters based on some custom classes, but have still had to send the email via code or via the send email page in the admin where I have added code to populate custom variables, something like the following. There is still coding involved but the email can be sent manually.
Then in the email template I have code like:
I have created new template parameters based on some custom classes, but have still had to send the email via code or via the send email page in the admin where I have added code to populate custom variables, something like the following. There is still coding involved but the email can be sent manually.
Code: Select all
if (Request.QueryString["OrderNumber"] != null)
{
int orderNumber = AlwaysConvert.ToInt(Request.QueryString["OrderNumber"]);
int orderId = OrderDataSource.LookupOrderId(orderNumber);
CommerceBuilder.Orders.Order order = OrderDataSource.Load(orderId);
Hashtable customParameters = xxxCustomEmailParameters.GetAllCustomTemplateVariablesForOrder(order);
foreach (DictionaryEntry entry in customParameters)
{
if (!mergeTemplate.Parameters.Contains(entry))
{
mergeTemplate.Parameters.Add(entry.Key, entry.Value);
}
}
}
Code: Select all
#set($itemvar="")
#foreach($itemvar in $itemvariables)
..........
#set ($itemstatus = $itemvar.itemstatus)
#if($itemstatus.Length>0)
Status: $itemstatus
#end
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
-
- Lieutenant (LT)
- Posts: 66
- Joined: Mon Jun 22, 2009 5:49 pm
Re: Referencing custom data in email template
Thanks. Any idea why I'm not getting emails? I've verified emailTemplate is not null. Nothing in spam.
EmailTemplate emailTemplate = EmailTemplateDataSource.Load(1);
if (emailTemplate != null)
{
emailTemplate.Parameters["recipient"] = "rsilver@gmail.com";
emailTemplate.ToAddress = "rsilver@gmail.com";
emailTemplate.Send();
}
EmailTemplate emailTemplate = EmailTemplateDataSource.Load(1);
if (emailTemplate != null)
{
emailTemplate.Parameters["recipient"] = "rsilver@gmail.com";
emailTemplate.ToAddress = "rsilver@gmail.com";
emailTemplate.Send();
}
Re: Referencing custom data in email template
Try setting up the store to make sure it is not null. Your code becomes something like:
Code: Select all
EmailTemplate emailTemplate = EmailTemplateDataSource.Load(1);
if (emailTemplate != null)
{
emailTemplate.Parameters["recipient"] = "rsilver@gmail.com";
emailTemplate.ToAddress = "rsilver@gmail.com";
emailTemplate.Parameters["store"] = AbleContext.Current.Store;
emailTemplate.Send();
}