Email customers?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
gio50000
Commander (CMDR)
Commander (CMDR)
Posts: 123
Joined: Mon Feb 18, 2008 12:51 pm
Location: Orlando, FL
Contact:

Email customers?

Post by gio50000 » Tue Nov 04, 2008 10:06 am

How can I send an email to all of my users?

Thanks,
Gio
Thank you,
Gio

User avatar
gio50000
Commander (CMDR)
Commander (CMDR)
Posts: 123
Joined: Mon Feb 18, 2008 12:51 pm
Location: Orlando, FL
Contact:

Re: Email customers?

Post by gio50000 » Tue Nov 04, 2008 10:17 am

I created an email list to contact users. Is there a way to add all users at once rather than one at a time?

Gio
Thank you,
Gio

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Email customers?

Post by mazhar » Tue Nov 04, 2008 10:53 am

You have to add the customers one by one to the Email list.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Email customers?

Post by mazhar » Tue Nov 04, 2008 10:58 am

Here is the helper code. The following changes will make two buttons available on the ManageUsers page will allow you to add/remove all users from the Email list in one go.

Please take backup of your Admin\Marketing\Email\ManageUsers.aspx and Admin\Marketing\Email\ManageUsers.aspx.cs files before making these changes.

Edit your Admin\Marketing\Email\ManageUsers.aspx file and locate the following line of code

Code: Select all

<asp:ObjectDataSource ID="SearchUsersDs" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="FindUsersByName" TypeName="CommerceBuilder.Users.UserDataSource"
and put the following code just above it so that it should look like as below

Code: Select all

<asp:Button ID="AddAllUsersButton" runat="server" OnClientClick="return confirm('Do you want to add all users to this Email list?');" OnClick="AddAllUsersButton_Click"
                        Text="Add All" />
                    <asp:Button ID="RemoveAllUsersButton" runat="server" OnClick="RemoveAllUsersButton_Click" OnClientClick="return confirm('Do you want to remove all users from this Email list?');"
                        Text="Remove All" /><br />

                            <asp:ObjectDataSource ID="SearchUsersDs" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="FindUsersByName" TypeName="CommerceBuilder.Users.UserDataSource"
Now edit your Admin\Marketing\Email\ManageUsers.aspx.cs file and add following two methods to it

Code: Select all

protected void AddAllUsersButton_Click(object sender, EventArgs e)
    {

        UserCollection users = UserDataSource.FindUsersByName(String.Empty,UserDataSource.NameSearchField.Email);
        foreach (User user in users)
        {
            if(!_EmailList.IsMember(user.UserName))
                _EmailList.AddMember(user.UserName, LocaleHelper.LocalNow, Request.UserHostAddress);
        }
        Response.Redirect(Request.Url.ToString());
    }
    protected void RemoveAllUsersButton_Click(object sender, EventArgs e)
    {
        UserCollection users = UserDataSource.FindUsersByName(String.Empty, UserDataSource.NameSearchField.Email);
        foreach (User user in users)
        {
            if (_EmailList.IsMember(user.UserName))
                _EmailList.RemoveMember(user.UserName);
        }
        Response.Redirect(Request.Url.ToString());
    }

User avatar
gio50000
Commander (CMDR)
Commander (CMDR)
Posts: 123
Joined: Mon Feb 18, 2008 12:51 pm
Location: Orlando, FL
Contact:

Re: Email customers?

Post by gio50000 » Tue Nov 04, 2008 12:29 pm

mazhar - the helper code worked perfectly!

Thank you,
Gio
Thank you,
Gio

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Email customers?

Post by mazhar » Tue Nov 04, 2008 12:43 pm

That's great. The option for adding or removing the users in bulk will be very helpful, so I just created an enhancement request for the future version.

Post Reply