Page 1 of 1

using an email template

Posted: Tue Nov 23, 2010 7:58 pm
by RickSilver
I need to be able to add a new email template through the admin screens and then in .net code, after checkout, read the template contents (Bonus: with NVelocity variables filled in) so that I can email the contents to a data-driven dynamic email address that we are storing in a custom database table. Is this possible? We are using the latest version AC 7*.

Thanks!
Rick S

Re: using an email template

Posted: Wed Nov 24, 2010 5:49 am
by mazhar
If you custom data is available under standard $order variables then all you need is to create new Email template in admin, assign order placed trigger to it and then do the nvelocity in its content section. Finally instead of having customer in its to address simply fill in the desired Email address where you want to send the message. If this new Email template requires some new nvelocity variables which are not available in Order Placed trigger context then you need to send the mail manually and by setting custom parameters on it.

Re: using an email template

Posted: Mon Nov 29, 2010 10:01 pm
by RickSilver
mazhar,
Thanks for the reply but I am somewhat confused. The custom data is an email address, but where do I "intercept" the trigger of an order so that I can substitute the customer email address with a different one? This is not an email address I know of until the order is placed. It is not a customer email address but one based on data from a custom database table.

Assuming I do have to do this manually, I'm back to my original question.

Rick

Re: using an email template

Posted: Tue Nov 30, 2010 4:15 am
by mazhar
Seems like you will be required to trigger Email manually. Read following thread about how to send Email manually
viewtopic.php?f=42&t=13537

You need to intecept order placed in ConLib/OnePageCheckout.ascx.cs file's CheckedOut method.

Re: using an email template

Posted: Tue Nov 30, 2010 7:34 pm
by RickSilver
Will I be able to store the contents of the email and the NVelocity tags in an email template from the admin screen? If so, how do I access the contents of the email template in OnePageCheckout.ascx.cs?

I guess this goes back to my original question...

I need to be able to add a new email template through the admin screens and then in .net code, after checkout, read the template contents (Bonus: with NVelocity variables filled in) so that I can email the contents to a data-driven dynamic email address that we are storing in a custom database table.


If not, where can I store the email template? I don't want it hard-coded in the code.

Rick

Re: using an email template

Posted: Wed Dec 01, 2010 4:58 am
by mazhar
If you read in detail the link that I provided in my comment above, you will see that you will create an Email template from admin side. Then from store side you will load and set parameters on that template and finally trigger Email. For example in the link that I mentioned I did something like

Code: Select all

EmailTemplateCollection emailTemplates = EmailTemplateDataSource.LoadForCriteria(" Name = 'Customer Order Notification' ");
in this case I loaded Customer Order Notification template using its name.

Re: using an email template

Posted: Wed Dec 01, 2010 8:20 am
by RickSilver
Thank you very much.

Rick