Page 1 of 1

New Email Triggers

Posted: Fri Oct 24, 2008 9:19 am
by William_firefold
We need two new email triggers for the site if anyone is available to help.We want triggers for:
-When a customer Registers, not for verification, but just a welcome email.
-When an order is switched to "sent to warehouse".

What code do I need to put where so that I can do this?

Re: New Email Triggers

Posted: Fri Oct 24, 2008 10:13 am
by mazhar
Well as discussed before in some other threads it is not possible to create new triggers so that store can send notifications based upon them. You have to load and send Email template manually from the location where action is performed. For example if want to send the Email notification when some customer is registered you need do the following.

1)- Create a new Email Template

For this go to admin side and create a new Email template for example just say it "New Registration" and specify its subject as below
Subject: Registration at $store.Name
and contents as
Contents: Hello, $customer.UserName welcome to $store.Name

and save this template.

2)- Email Code

Code: Select all

EmailTemplateCollection emailTemplates = EmailTemplateDataSource.LoadForCriteria(" Name = 'New Registration' ");
                        if (emailTemplates.Count > 0)
                        {
                            emailTemplates[0].Parameters.Add("store", Token.Instance.Store);
                            emailTemplates[0].Parameters.Add("customer", newUser);
                            emailTemplates[0].ToAddress = newUser.UserName;
                            emailTemplates[0].Send();
                        }
In this step first I loaded the desired template and then i need two NVelocity parameters which i used in the Email Template the store and customer, Then i provided the ToAddress where i want to send the Email.
You will provide this code where the registeration is being done in this case it will be in RegisterDialog conlib control. You can place the code just above the following line in this control

Code: Select all

//REDIRECT TO APPROPRIATE PAGE
                    FormsAuthentication.RedirectFromLoginPage(UserName.Text, false);
You can create the other one using the same technique.

Re: New Email Triggers

Posted: Fri Oct 24, 2008 10:42 am
by William_firefold
Perfect. Thank you for your reply. This should work great.

Login Redirect

Posted: Thu Jun 18, 2009 3:40 am
by bha
How do I control where

FormsAuthentication.RedirectFromLoginPage(UserName.Text, false);

is redirected?

A common confusion is when a customer has logged in, they don't realize it because the logged in page is so similar. I would like to redirect to their member account page for example or a welcome screen with their name.

Thanks.

Re: New Email Triggers

Posted: Thu Jun 18, 2009 7:46 am
by mazhar
Try following trick
Edit your website/web.config file and then locate following line

Code: Select all

<forms timeout="90" slidingExpiration="true" name="AC7.ASPXAUTH" />
and change it as below

Code: Select all

<forms timeout="90" slidingExpiration="true" name="AC7.ASPXAUTH" defaultUrl="~/Members/MyAccount.aspx"/>

Re: New Email Triggers

Posted: Thu Jun 18, 2009 11:47 am
by bha
Excellent! Worked Perfectly. Thanks.