Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 16 of 16

Thread: Helpful for newsletters and subscriptions receiving w/c doesn't require registration

  1. #1
    Jao is offline Senior Member
    Join Date
    Oct 2008
    Posts
    1,132

    Default Helpful for newsletters and subscriptions receiving w/c doesn't require registration

    Here's just a simple pass-through procedure/way which will allow you to send a bulk email (one per email address actually) to each enlisted email address which is not even a customer but wanted to receive newsletters, offers, etc from your site; however, this is not yet full-blown, fortunately, the software is flexible and is easy to manipulate, you can still add some validator and some other stuff to make this suit your needs. I bet it would just take a few moments of your time. First create a table by running this script:
    Code:
    CREATE TABLE [dbo].[MailingList]([EmailAddress] [nvarchar](100) NOT NULL,[SubscriptionExpiresOn] [datetime],[IsRegistered][tinyint],[CreatedOn] [datetime] NOT NULL CONSTRAINT DF_MailingList_CreatedOn DEFAULT(getdate())) end GO
    Note: You may also add the OkToEmail column to simply flag the record. I prefer complete addition/deletion to save up resources and to avoid confusion.

    Then execute another script, which is presented below, to copy the existing Email Addresses from the Customer table to this new table; however, take note, this will only copy those email address where the OkToEmail column value is 1.
    Code:
    DECLARE @EmailAdd nvarchar(100), @Subscribe datetime;
    DECLARE MyCursor CURSOR FOR
    	SELECT Email, SubscriptionExpiresOn
    	FROM Customer
    	WHERE Email <>'' and OkToEmail = 1 Order By Email
    OPEN MyCursor;
    FETCH NEXT FROM MyCursor
    INTO @EmailAdd, @Subscribe;
    WHILE @@FETCH_STATUS = 0
       BEGIN
    		INSERT into dbo.MailingList (EmailAddress,IsRegistered,SubscriptionExpiresOn,CreatedOn)
    		VALUES (@EmailAdd,1,@Subscribe,getdate())
    		FETCH NEXT FROM MyCursor INTO @EmailAdd, @Subscribe;
       END;
    CLOSE MyCursor;
    DEALLOCATE MyCursor;
    GO
    You will also need to add the following script in the existing aspdnsf_updCustomer stored procedure
    Code:
    IF exists (select EmailAddress from MailingList Address where EmailAddress = @Email) begin
    	UPDATE dbo.MailingList SET 
    		EmailAddress = COALESCE(@Email, EmailAddress),
    		IsRegistered = COALESCE(@IsRegistered, IsRegistered),
    		SubscriptionExpiresOn = COALESCE(@SubscriptionExpiresOn, SubscriptionExpiresOn)
    	WHERE EmailAddress = @Email
    end
    else
    begin
    IF @OkToEmail = 1 and @Email is not null
    	INSERT dbo.MailingList (EmailAddress,IsRegistered,SubscriptionExpiresOn,CreatedOn)
    	VALUES (isnull(@Email, ''),isnull(@IsRegistered,''),isnull(@SubscriptionExpiresOn,''),getdate())
    end
    Then create your own stored procedure, this will be used to create a record to the MailingList from the form which will be created to prompt user to add his email address (it's a new separate form, which does not require user to register a customer account)
    Code:
    create proc dbo.aspdnsf_insMailingList
        @Email nvarchar(100)
    AS
    SET NOCOUNT ON
    insert dbo.MailingList(EmailAddress,IsRegistered, SubscriptionExpiresOn, CreatedOn) values(isnull(@Email, ''),0,null,getdate())
    Next, we will modify the Admin/mailingmgr.aspx.cs. We will add the following code to enable admin to add email address to MailingList. (Add these lines at the lower part of the RenderContents method, just next to the writer.Write("</form>");
    Code:
                writer.Write("<hr size=\"1\"/>"); //optional
                writer.Write("</div>");
                writer.Write("<div align=\"left\">\n");
                writer.Write("<b>USE THE FOLLOWING FORM TO ADD SOMEONE TO THE MAILING LIST:</b><br/><br/>\n");
                writer.Write("<form action=\"mailingmgr.aspx\" method=\"post\" id=\"Form3\" name=\"Form3\">\n");
                writer.Write("<b>Add an E-Mail to Mailing List:</b> <input maxLength=\"100\" size=\"30\" name=\"AddEMail\" value=\"\">\n");
                writer.Write("&nbsp;&nbsp;<input class=\"normalButtons\" type=\"submit\" value=\"Add\" name=\"submit\">\n");
                writer.Write("</form>");
                writer.Write("</div>");
    Also, look for this line:
    Code:
    DB.ExecuteSQL("update customer set OKToEMail=0 where EMail=" + DB.SQuote(CommonLogic.FormCanBeDangerousContent("RemoveEMail").ToLowerInvariant()));
    and add the line below next to the above code
    Code:
    DB.ExecuteSQL("delete from MailingList where EmailAddress =" + DB.SQuote(CommonLogic.FormCanBeDangerousContent("RemoveEMail").ToLowerInvariant()));
    Again, this will depend on you, if you prefer the flagging, make sure, you've added the OkToEmail column or the complete deletion like this, which will actually delete the record from the MailingList, after the end of the if (CommonLogic.FormCanBeDangerousContent("RemoveEMai l").Length != 0) statement block, add the following:
    Code:
    if (CommonLogic.FormCanBeDangerousContent("AddEMail").Length != 0)
    {
    DB.ExecuteSQL("insert into MailingList(EmailAddress,IsRegistered,SubscriptionExpiresOn,CreatedOn) values (" + DB.SQuote(CommonLogic.FormCanBeDangerousContent("AddEMail").ToLowerInvariant()) + ",0, null," + DB.DateQuote(Localization.ToDBDateTimeString(System.DateTime.Now)) + ")");
    writer.Write("<p align=\"left\"><b>Email Address Added... <br/></b></p>");
    }
    Then look for this line:
    Code:
    String CustSQL = "select COUNT(CustomerGUID) AS N from Customer  with (NOLOCK)  where EMail like '%@%' and EMail not in (select ToEMail from mailingmgrlog  with (NOLOCK)  where month(senton)=" + System.DateTime.Now.Month.ToString() + " and day(senton)=" + System.DateTime.Now.Day.ToString() + " and year(SentOn)=" + System.DateTime.Now.Year.ToString() + " and Subject=" + DB.SQuote(Subject) + ") and Deleted=0 and OKToEMail=1 and EMail <> '' " + CommonLogic.IIF(CustomerLevelID != 0, " and CustomerLevelID=" + CustomerLevelID.ToString(), "") + CommonLogic.IIF(ordersonly, " and CustomerID in (select distinct CustomerID from Orders  with (NOLOCK)  where FraudedOn IS NULL and TransactionState=" + DB.SQuote(AppLogic.ro_TXStateCaptured) + ")", "") + ";" + "select CustomerGUID,EMail from Customer  with (NOLOCK)  where EMail like '%@%' and EMail not in (select ToEMail from mailingmgrlog  with (NOLOCK)  where month(senton)=" + System.DateTime.Now.Month.ToString() + " and day(senton)=" + System.DateTime.Now.Day.ToString() + " and year(SentOn)=" + System.DateTime.Now.Year.ToString() + " and Subject=" + DB.SQuote(Subject) + ") and Deleted=0 and OKToEMail=1 and EMail <> '' " + CommonLogic.IIF(CustomerLevelID != 0, " and CustomerLevelID=" + CustomerLevelID.ToString(), "") + CommonLogic.IIF(ordersonly, " and CustomerID in (select distinct CustomerID from Orders  with (NOLOCK)  where FraudedOn IS NULL and TransactionState=" + DB.SQuote(AppLogic.ro_TXStateCaptured) + ")", "") + " order by CustomerID";
    And change it to this (although, I'm totally unsure of this aspect) This part I'm not 100% sure, if you will need to change that line or just look for a way change the script to somehow filter the MailingList count and will also apply the mailing rules. Feel free to comment.
    Code:
    String CustSQL = "select COUNT(EmailAddress) AS N, EmailAddress From MailingList";
    If you however, use my tentative method, look and comment the following also:
    Code:
    //guid = new String[count];
    //guid[NumEMails] = DB.RSField(rs, "CustomerGUID");
    //guid = new String[count];
    //guid = new String[0];
    //+ guid[i]);   -----> add the ); at the end of that line after commenting this out.
    //String EM = DB.RSField(rs, "EMail");
    At this: String EM = DB.RSField(rs, "EMailAddress"); as a replacement to the last item.

    Then create the page.mailinglist.xml.config. Make sure it'll reside on the root/XmlPackages folder
    Code:
    <?xml version="1.0" standalone="yes" ?>
    <package version="2.1" displayname="Search" debug="false" includeentityhelper="false">
      <query name="Email" rowElementName="EmailAddress" runif="AddEmail">
        <sql>
          <![CDATA[
                    exec aspdnsf_insMailingList @AddEmail
                ]]>
        </sql>
        <queryparam paramname="@AddEmail" paramtype="request" requestparamname="AddEmail" sqlDataType="varchar" defvalue=""  validationpattern="" />
      </query>
      <PackageTransform>
        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
          <xsl:output method="html" omit-xml-declaration="yes" />
          <xsl:template match="/">
              <form action="index.aspx" method="post" id="AddEmailForm" name="AddEmailForm">
                <input maxLength="100" size="32" name="AddEMail" value="{/root/QueryString/addemail}"/>
                  <input type="submit" value="Subscribe" name="submit"/>
              </form>
          </xsl:template>
        </xsl:stylesheet>
      </PackageTransform>
    </package>
    It should look like this image: Name:  addemail.gif
Views: 758
Size:  3.7 KB
    Then add this section wherever you want to play the AddEmailForm (as a skin token, though) SkinToken: (!ADDEMAIL!)
    Code:
    <div id="leftWrap"><div class="navHeader">Add your Email here</div>        
    (!ADDEMAIL!)
    </div><br />
    Then add an AppConfig, name it, ShowAddEmailForm, value can be true or false. Then add the following codes in the BuildPageDynamicTokens method of the Parser.cs
    Code:
    if (AppLogic.AppConfigBool("ShowAddEmailForm"))
    {
    m_DynamicTokens.Add("(!ADDEMAIL!)", ShoppingCart.DisplayAddEmailForm(ThisCustomer, SkinID, false));
    }
    else
    {
    m_DynamicTokens.Add("(!ADDEMAIL!)", String.Empty);
    }
    Lastly, add the following line of codes in the GetFreeShippingReason method of the ShoppingCart.cs, although, you can place it anywhere. I only used this to mimic the behavior of MINICART
    Code:
    public static String DisplayAddEmailForm(Customer ThisCustomer, int m_SkinID, bool IncludeFrame)
    {
    return AppLogic.RunXmlPackage("page.mailinglist.xml.config", null, ThisCustomer, m_SkinID, "", "", false, false);
    }
    AGAIN PLEASE FEEL FREE TO GIVE COMMENT/SUGGESTION. IT WILL BE MUCH APPRECIATED.
    Last edited by Jao; 04-02-2009 at 10:08 PM.

  2. #2
    sugith_k is offline Member
    Join Date
    Mar 2009
    Posts
    97

    Question

    In your explanation of doing this newsletter, you have mentioned that

    "Then add an AppConfig, name it, ShowAddEmailForm, value can be true or false. Then add the following codes in the BuildPageDynamicTokens method of the Parser.cs

    Code:

    if (AppLogic.AppConfigBool("ShowAddEmailForm"))
    {
    m_DynamicTokens.Add("(!ADDEMAIL!)", ShoppingCart.DisplayAddEmailForm(ThisCustomer, SkinID, false));
    }
    else
    {
    m_DynamicTokens.Add("(!ADDEMAIL!)", String.Empty);
    }


    "

    Can you tell me, when I am adding an AppConfig from the backend,what do I have to select from the dropdown? And from where I can find this Parser.cs ?

  3. #3
    Jao is offline Senior Member
    Join Date
    Oct 2008
    Posts
    1,132

    Default

    You could select whatever group you want that new AppConfig be included to. I actually added it on the Display group, you can also do the same, considering that it somewhat relates to it. The Parser.cs file is actually located in the ASPDNSFCommon folder if you have the source code for 7.x versions or in the ASPDNSFCore for 8.x versions.

  4. #4
    sugith_k is offline Member
    Join Date
    Mar 2009
    Posts
    97

    Default

    What if I don't have the source code with me? Aren't there anything else that I can do to make it work?

  5. #5
    mgibbs is offline Senior Member
    Join Date
    Jan 2005
    Location
    Orange County, CA
    Posts
    194

    Default

    Great Post Joe. This is an extremely in-depth discussion of how to extend the product with source availability. This will work as a template for a number of other projects (not-email related) I've been working on so I appreciate it!

    For those without source code access, there are alternatives to get subscribers into the customer or an external database (hint, see signature below )
    EMM for AspDotNetStorefront - Communicate effectively with your customers

  6. #6
    sugith_k is offline Member
    Join Date
    Mar 2009
    Posts
    97

    Default

    Can't I just fix it from the xml?

  7. #7
    sugith_k is offline Member
    Join Date
    Mar 2009
    Posts
    97

    Exclamation

    I did everything that you have mentioned above to make this newsletter subscribe works. Since I don't have the source code, I couldn't do the changes to the last two things that have mentioned. I assume that you have done in there is making a token which can be used in anywhere.

    For that I used (!XmlPackage Name="page.mailinglist"!) in the home page template, so that I can invoke the xml and make it work in my home page.

    but the problem is that I am getting an error which is

    "
    Compilation Error
    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS0115: 'ASP.newsletter_process_aspx.GetTypeHashCode()': no suitable method found to override

    Source Error:

    Line 179:
    Line 180: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
    Line 181: public override int GetTypeHashCode() {
    Line 182: return 5381;
    Line 183: }


    Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET Files\root\ea32f864\a8eb1030\App_Web_newsletter_pr ocess.aspx.cdcab7d2.okny_in2.0.cs Line: 181


    "

    please if someone can help me out to make this thing work..

    thank you,

    Sugith_k

  8. #8
    Jao is offline Senior Member
    Join Date
    Oct 2008
    Posts
    1,132

    Default

    That would do also, but please make sure that you place the exact filename of the xmlpackage (e.g. page.mailinglist.xml.config)

  9. #9
    sugith_k is offline Member
    Join Date
    Mar 2009
    Posts
    97

    Question

    I have set the settings as you have mentioned but I am getting this error which I was mentioned in the previous post.Do you have any idea of why I getting such an error?


    thank you,
    Sugith_k

  10. #10
    sugith_k is offline Member
    Join Date
    Mar 2009
    Posts
    97

    Question

    I figure out what that error was but still this subscription feature does not work. Is that because I haven't done the last three changes as you have mentioned in your scenario?

    Since I don't have the source code, what I did was I added the (!XmlPackage Name="page.mailinglist"!) instead of making those TOKENS. Tell me what I did wrong please.

    Thank you
    Sugith_k

  11. #11
    Jao is offline Senior Member
    Join Date
    Oct 2008
    Posts
    1,132

    Default

    I've already posted my reply. I've stated that you can also call the XmlPackage in the template.ascx. Just make sure you've stated the complete filename of the XmlPackage.

  12. #12
    sugith_k is offline Member
    Join Date
    Mar 2009
    Posts
    97

    Thumbs up

    Thanks it worked.


    Sugith_k

  13. #13
    sugith_k is offline Member
    Join Date
    Mar 2009
    Posts
    97

    Default

    What are the options that I have to set the mailing DNS? I used SMTP and it did not work. I used google SMTP and yahoo.

    Can someone tell me how it should be set please.

    Thank you

    Sugith_k

  14. #14
    Fean0r is offline Senior Member
    Join Date
    Nov 2009
    Posts
    145

    Default

    Thanks I got this running without the source code.

    Using: (!XmlPackage Name="page.mailinglist.xml.config"!)

    The only thing left to do is validate the email feild, is there anything built in we can use?
    Version: ML 8.0.1.2 and No Source Code.

  15. #15
    ASPAlfred is offline Senior Member
    Join Date
    Nov 2007
    Posts
    2,244

    Default

    You can add a javascript funtion there with a predefined email regex e.g.(''\w+([-+.'']w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*''), say CheckValidEmail() then add an Onclick event inside <Input type="Submit" Onclick="CheckValidEmail()".../>. Your javascript should look like below:

    Code:
    <script type="text/javascript">
    function CheckValidEmail()
    {
    var ergx = new RegExp(''\w+([-+.'']w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*'');  
    if(!ergx.test(document.getElementById("AddEMail").value))
    {
    alert("Invalid Email.");
    return false;
    }
    }
    </script>

  16. #16
    gmaniac is offline Member
    Join Date
    Jul 2010
    Location
    Missouri
    Posts
    59

    Default Error on mailingmgr.aspx.cs

    So I am having trouble on my mailing manager page on the admin side. It seems to not be filling s with anything. The error I was receiving back was:

    Line 167: string Footer = sFooter.Replace(@"%REMOVEURL%", AppLogic.GetStoreHTTPLocation(false) + "remove.aspx?id="); //+ guid[i]);
    Line 168: String ToThisPerson = s[i];
    Line 169: writer.Write(CommonLogic.IIF(listonly, "JUST LISTING ADDRESS:<br/>", "SENDING LIVE TO:<br/>") + ToThisPerson + "...<br/>");
    Line 170: try
    Here is my mailingmgr.aspx.cs file with all of the commented out and added sections included:

    Code:
    // ------------------------------------------------------------------------------------------
    // Copyright AspDotNetStorefront.com, 1995-2009.  All Rights Reserved.
    // http://www.aspdotnetstorefront.com
    // For details on this license please visit  the product homepage at the URL above.
    // THE ABOVE NOTICE MUST REMAIN INTACT. 
    // ------------------------------------------------------------------------------------------
    using System;
    using System.Data;
    using System.Globalization;
    using System.Text;
    using System.Web;
    using System.IO;
    using System.Web.UI;
    //using ASPDNSFEditor;
    using ASPDNSF_RadWrapper;
    using AspDotNetStorefrontCore;
    using System.Data.SqlClient;
    
    namespace AspDotNetStorefrontAdmin
    {
        /// <summary>
        /// Summary description for mailingmgr
        /// </summary>
        public partial class mailingmgr : AspDotNetStorefront.SkinBase
        {
    
            protected void Page_Load(object sender, System.EventArgs e)
            {
                Response.CacheControl = "private";
                Response.Expires = 0;
                Response.AddHeader("pragma", "no-cache");
    
                Server.ScriptTimeout = 50000;
                SectionTitle = "Mailing Manager";
    
                if (AppLogic.ProductIsMLX())
                {
                    Response.Redirect("restrictedfeature.aspx");
                }
            }
    
            protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
            {
                if (!AppLogic.AppConfigBool("TurnOffHtmlEditorInAdminSite"))
                {
                    writer.Write("<script language=\"Javascript\" src=\"Editor/scripts/innovaeditor.js\"></script>");
                }
    
                if (CommonLogic.FormCanBeDangerousContent("RemoveEMail").Length != 0)
                {
                    DB.ExecuteSQL("update customer set OKToEMail=0 where EMail=" + DB.SQuote(CommonLogic.FormCanBeDangerousContent("RemoveEMail").ToLowerInvariant()));
    				DB.ExecuteSQL("delete from MailingList where EmailAddress =" + DB.SQuote(CommonLogic.FormCanBeDangerousContent("RemoveEMail").ToLowerInvariant()));
                    writer.Write("<p align=\"left\"><b>Customer Removed...<br/></b></p>");
                }
    			
    			if (CommonLogic.FormCanBeDangerousContent("AddEMail").Length != 0)
    			{
    				DB.ExecuteSQL("insert into MailingList(EmailAddress,IsRegistered,SubscriptionExpiresOn,CreatedOn) values (" + DB.SQuote(CommonLogic.FormCanBeDangerousContent("AddEMail").ToLowerInvariant()) + ",0, null," + DB.DateQuote(Localization.ToDBDateTimeString(System.DateTime.Now)) + ")");
    				writer.Write("<p align=\"left\"><b>Email Address Added... <br/></b></p>");
    			}
    
                Topic t = new Topic("MailFooter", ThisCustomer.LocaleSetting, SkinID);
                String sFooter = t.Contents;
                if (CommonLogic.FormBool("IsSubmit"))
                {
                    String Subject = CommonLogic.FormCanBeDangerousContent("Subject");
                    String Body = CommonLogic.FormCanBeDangerousContent("MessageBodyText");
                    int CustomerLevelID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent("CustomerLevelID"));
                    String FromEMail = AppLogic.AppConfig("ReceiptEMailFrom");
                    String FromName = AppLogic.AppConfig("ReceiptEMailFromName");
                    String ToEMail = String.Empty;
                    String FromServer = AppLogic.MailServer();
    
                    // On a demo site, Mass Mailing Manager will ONLY send to test address
                    bool testing = (CommonLogic.FormCanBeDangerousContent("TESTONLY") == "1") ||
                        AspDotNetStorefront.Global.LicenseInfo("isdemosite").Equals("True", StringComparison.InvariantCultureIgnoreCase);
    
                    bool ordersonly = (CommonLogic.FormCanBeDangerousContent("ORDERSONLY") == "1");
                    bool listonly = (CommonLogic.FormCanBeDangerousContent("LISTONLY") == "1");
                    writer.Write("<div align=\"left\">");
                    String tmpS = String.Empty;
                    String ToList = String.Empty;
                    if (testing)
                    {
                        writer.Write("Sending TEST to: " + FromEMail + "...");
                        try
                        {
                            AppLogic.SendMail(Subject, Body + sFooter, true, FromEMail, FromName, FromEMail, FromName, "", FromServer);
                        }
                        catch (Exception ex)
                        {
                            writer.Write(CommonLogic.GetExceptionDetail(ex, "<br/>"));
                        }
                        writer.Write("done<br/>");
                        writer.Flush();
                    }
                    else
                    {
                        //String CustSQL = "select COUNT(CustomerGUID) AS N from Customer  with (NOLOCK)  where EMail like '%@%' and EMail not in (select ToEMail from mailingmgrlog  with (NOLOCK)  where month(senton)=" + System.DateTime.Now.Month.ToString() + " and day(senton)=" + System.DateTime.Now.Day.ToString() + " and year(SentOn)=" + System.DateTime.Now.Year.ToString() + " and Subject=" + DB.SQuote(Subject) + ") and Deleted=0 and OKToEMail=1 and EMail <> '' " + CommonLogic.IIF(CustomerLevelID != 0, " and CustomerLevelID=" + CustomerLevelID.ToString(), "") + CommonLogic.IIF(ordersonly, " and CustomerID in (select distinct CustomerID from Orders  with (NOLOCK)  where FraudedOn IS NULL and TransactionState=" + DB.SQuote(AppLogic.ro_TXStateCaptured) + ")", "") + ";" + "select CustomerGUID,EMail from Customer  with (NOLOCK)  where EMail like '%@%' and EMail not in (select ToEMail from mailingmgrlog  with (NOLOCK)  where month(senton)=" + System.DateTime.Now.Month.ToString() + " and day(senton)=" + System.DateTime.Now.Day.ToString() + " and year(SentOn)=" + System.DateTime.Now.Year.ToString() + " and Subject=" + DB.SQuote(Subject) + ") and Deleted=0 and OKToEMail=1 and EMail <> '' " + CommonLogic.IIF(CustomerLevelID != 0, " and CustomerLevelID=" + CustomerLevelID.ToString(), "") + CommonLogic.IIF(ordersonly, " and CustomerID in (select distinct CustomerID from Orders  with (NOLOCK)  where FraudedOn IS NULL and TransactionState=" + DB.SQuote(AppLogic.ro_TXStateCaptured) + ")", "") + " order by CustomerID";
                        String CustSQL = "SELECT COUNT(EmailAddress) AS N, EmailAddress FROM MailingList GROUP BY EmailAddress";
                        
                        int NumEMails = 0;
                        String[] s;
                        //String[] guid;
    
    
                        using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                        {
                            dbconn.Open();
                            using (IDataReader rs = DB.GetRS(CustSQL, dbconn))
                            {
                                if (rs.Read() && DB.RSFieldInt(rs, "N") > 0)
                                {
                                    int count = DB.RSFieldInt(rs, "N");
                                    if (rs.NextResult())
                                    {
                                        NumEMails = 0;
                                        s = new String[count];
                                        //guid = new String[count];
    
                                        while (rs.Read())
                                        {
                                            //String EM = DB.RSField(rs, "EMail");
                                            String EM = DB.RSField(rs, "EmailAddress");
                                            bool EMailIsValid = true;
                                            if (EMailIsValid)
                                            {
                                                s[NumEMails] = EM;
                                                //guid[NumEMails] = DB.RSField(rs, "CustomerGUID");
                                                NumEMails++;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        NumEMails = 0;
                                        s = new String[count];
                                        //guid = new String[count];
                                    }
                                }
                                else
                                {
                                    NumEMails = 0;
                                    s = new String[0];
                                    //guid = new String[0];
                                }
                            }
                        }
    
                        int BCCSize = AppLogic.AppConfigUSInt("MailingMgr.BlockSize");
                        if (BCCSize == 0)
                        {
                            BCCSize = 5; // default
                        }
                        if (AppLogic.AppConfigBool("MailingMgr.SendEachEMailSeparately"))
                        {
                            // send each e-mail separately:
                            for (int i = 0; i < NumEMails; i++)
                            {
                                string Footer = sFooter.Replace(@"%REMOVEURL%", AppLogic.GetStoreHTTPLocation(false) + "remove.aspx?id="); //+ guid[i]);
                                String ToThisPerson = s[i];
                                writer.Write(CommonLogic.IIF(listonly, "JUST LISTING ADDRESS:<br/>", "SENDING LIVE TO:<br/>") + ToThisPerson + "...<br/>");
                                try
                                {
                                    if (!listonly)
                                    {
                                        AppLogic.SendMail(Subject, Body + Footer, true, FromEMail, FromName, ToThisPerson, ToThisPerson, String.Empty, FromServer);
                                        DB.ExecuteSQL("insert into MailingMgrLog(ToEMail,FromEMail,Subject,Body) values(" + DB.SQuote(ToThisPerson) + "," + DB.SQuote(FromEMail) + "," + DB.SQuote(Subject) + "," + DB.SQuote(Body) + ")");
                                    }
                                }
                                catch (Exception ex)
                                {
                                    writer.Write(CommonLogic.GetExceptionDetail(ex, "<br/>"));
                                }
                                writer.Write("done<br/>");
                                writer.Flush();
                            }
                        }
                        else
                        {
                            // send in groups of bcc's:
                            int i = 0;
                            string Footer = sFooter.Replace(@"%REMOVEURL%", String.Empty); // no way to do this really, so remove the remove link! 
                            while (i < NumEMails)
                            {
                                ToList = String.Empty;
                                for (int j = 1; j <= BCCSize && i < NumEMails; j++)
                                {
                                    if (ToList.Length != 0)
                                    {
                                        ToList += ";";
                                    }
                                    ToList += s[i];
                                    i++;
                                }
                                writer.Write(CommonLogic.IIF(listonly, "JUST LISTING ADDRESS:<br/>", "SENDING LIVE TO:<br/>") + ToList.Replace(";", "...<br/>") + "<br/>");
                                try
                                {
                                    if (!listonly)
                                    {
                                        AppLogic.SendMail(Subject, Body + Footer, true, FromEMail, FromName, FromEMail, FromName, ToList, FromServer);
                                        String[] sentto = ToList.Split(';');
                                        foreach (String ss in sentto)
                                        {
                                            DB.ExecuteSQL("insert into MailingMgrLog(ToEMail,FromEMail,Subject,Body) values(" + DB.SQuote(ss) + "," + DB.SQuote(FromEMail) + "," + DB.SQuote(Subject) + "," + DB.SQuote(Body) + ")");
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    writer.Write(CommonLogic.GetExceptionDetail(ex, "<br/>"));
                                }
                                writer.Write("done<br/>");
                                writer.Flush();
                            }
                        }
                    }
                    writer.Write("</div>");
                }
    
                if (ErrorMsg.Length != 0)
                {
                    writer.Write("<p><b><font color=red>" + ErrorMsg + "</font></b></p>\n");
                }
    
                writer.Write("<p align=\"left\">You may use this page to send e-mails to all registered customers who have chosen to accept e-mails. You can remove customers from the mailing list at the bottom of the page.</p>\n");
                writer.Write("<table width=\"100%\" cellpadding=\"4\" cellspacing=\"0\">\n");
                writer.Write("<form action=\"mailingmgr.aspx\" method=\"post\" id=\"Form1\" name=\"Form1\">\n");
                writer.Write("<input type=\"hidden\" name=\"IsSubmit\" value=\"true\">\n");
    
                writer.Write("<tr valign=\"middle\">\n");
                writer.Write("<td width=\"25%\" align=\"right\" valign=\"middle\">*Subject:&nbsp;&nbsp;</td>\n");
                writer.Write("<td align=\"left\">\n");
                writer.Write("<input maxLength=\"100\" size=\"30\" name=\"Subject\" value=\"" + CommonLogic.FormCanBeDangerousContent("Subject") + "\">\n");
                writer.Write("</td>\n");
                writer.Write("</tr>\n");
    
                writer.Write("<tr valign=\"middle\">\n");
                writer.Write("<td width=\"25%\" align=\"right\" valign=\"middle\">*TEST ONLY:&nbsp;&nbsp;</td>\n");
                writer.Write("<td align=\"left\">\n");
                writer.Write("Yes&nbsp;<INPUT TYPE=\"RADIO\" NAME=\"TESTONLY\" value=\"1\" checked>\n");
                writer.Write("No&nbsp;<INPUT TYPE=\"RADIO\" NAME=\"TESTONLY\" value=\"0\">\n");
                writer.Write("&nbsp;&nbsp;(if testing, only 1 e-mail will be sent to the store contact address)");
                writer.Write("</td>\n");
                writer.Write("</tr>\n");
    
                writer.Write("<tr valign=\"middle\">\n");
                writer.Write("<td width=\"25%\" align=\"right\" valign=\"middle\">*CUSTOMERS WITH ORDERS ONLY:&nbsp;&nbsp;</td>\n");
                writer.Write("<td align=\"left\">\n");
                writer.Write("Yes&nbsp;<INPUT TYPE=\"RADIO\" NAME=\"ORDERSONLY\" value=\"1\" checked>\n");
                writer.Write("No&nbsp;<INPUT TYPE=\"RADIO\" NAME=\"ORDERSONLY\" value=\"0\">\n");
                writer.Write("</td>\n");
                writer.Write("</tr>\n");
    
                writer.Write("<tr valign=\"middle\">\n");
                writer.Write("<td width=\"25%\" align=\"right\" valign=\"middle\">*LIST CUSTOMERS WHO WOULD BE E-MAILED ONLY:&nbsp;&nbsp;</td>\n");
                writer.Write("<td align=\"left\">\n");
                writer.Write("Yes&nbsp;<INPUT TYPE=\"RADIO\" NAME=\"LISTONLY\" value=\"1\" checked>\n");
                writer.Write("No&nbsp;<INPUT TYPE=\"RADIO\" NAME=\"LISTONLY\" value=\"0\">\n");
                writer.Write("&nbsp;&nbsp;(if list only, e-mails will not be sent)");
                writer.Write("</td>\n");
                writer.Write("</tr>\n");
    
    
                if (!AppLogic.ProductIsMLExpress())
                {
                    writer.Write("<tr valign=\"middle\">\n");
                    writer.Write("<td width=\"25%\" align=\"right\" valign=\"middle\">Customer Level:&nbsp;&nbsp;</td>\n");
                    writer.Write("<td align=\"left\">\n");
                    writer.Write("<select size=\"1\" name=\"CustomerLevelID\">\n");
                    writer.Write("<OPTION VALUE=\"0\" " + CommonLogic.IIF(CommonLogic.FormCanBeDangerousContent("CustomerLevelID") == "0", " selected ", "") + ">All Customers</option>\n");
    
                    using (SqlConnection dbconn = DB.dbConn())
                    {
                        dbconn.Open();
                        using (IDataReader rs = DB.GetRS("select * from CustomerLevel   with (NOLOCK)  where deleted=0 order by DisplayOrder,Name", dbconn))
                        {
                            while (rs.Read())
                            {
                                writer.Write("<option value=\"" + DB.RSFieldInt(rs, "CustomerLevelID").ToString() + "\"");
                                if (CommonLogic.FormUSInt("CustomerLevelID") == DB.RSFieldInt(rs, "CustomerLevelID"))
                                {
                                    writer.Write(" selected");
                                }
                                writer.Write(">" + DB.RSFieldByLocale(rs, "Name", ThisCustomer.LocaleSetting) + "</option>");
                            }
                        }
                    }
    
                    writer.Write("</select>\n");
                    writer.Write("</td>\n");
                    writer.Write("</tr>\n");
                }
    
                writer.Write("<tr valign=\"middle\">\n");
                writer.Write("<td width=\"25%\" align=\"right\" valign=\"top\">Message Body:&nbsp;&nbsp;</td>\n");
                writer.Write("<td align=\"left\">\n");
                
    
                writer.Write("<div id=\"idMessageBodyText\">");
                writer.Write("<textarea style=\"width: 100%;\" rows=\"40\" id=\"MessageBodyText\" name=\"MessageBodyText\">" + CommonLogic.FormCanBeDangerousContent("MessageBodyText") + "</textarea>\n");
                writer.Write(AppLogic.GenerateInnovaEditor("MessageBodyText"));
                writer.Write("</div>");
                writer.Write("</td>\n");
                writer.Write("</tr>\n");
    
                writer.Write("<tr valign=\"middle\">\n");
                writer.Write("<td width=\"25%\" align=\"right\" valign=\"top\">Message Footer (From Topic: MailFooter):&nbsp;&nbsp;</td>\n");
                writer.Write("<td align=\"left\">\n");
    
                sFooter = sFooter.Replace(@"%REMOVEURL%", AppLogic.GetStoreHTTPLocation(false) + "remove.aspx?id=" + ThisCustomer.CustomerGUID);
    
                writer.Write(sFooter);
                writer.Write("</td>\n");
                writer.Write("</tr>\n");
    
                writer.Write("<tr>\n");
                writer.Write("<td></td><td align=\"left\"><br/>\n");
                writer.Write("<input class=\"normalButtons\" type=\"submit\" value=\"Submit\" name=\"submit\">\n");
                writer.Write("</td>\n");
                writer.Write("</tr>\n");
                writer.Write("</form>\n");
                writer.Write("</table>\n");
    
                writer.Write("<hr size=\"1\"/>");
                writer.Write("<div align=\"left\">\n");
                writer.Write("<b>USE THE FORM BELOW TO REMOVE SOMEONE FROM THE MAILING LIST:</b><br/><br/>\n");
                writer.Write("<form action=\"mailingmgr.aspx\" method=\"post\" id=\"Form2\" name=\"Form2\">\n");
                writer.Write("<b>Remove Customer E-Mail From Mailing List:</b> <input maxLength=\"100\" size=\"30\" name=\"RemoveEMail\" value=\"\">\n");
                writer.Write("&nbsp;&nbsp;<input class=\"normalButtons\" type=\"submit\" value=\"Submit\" name=\"submit\">\n");
                writer.Write("</form>");
                writer.Write("</div>");
    			
    			writer.Write("<div align=\"left\">\n");
                writer.Write("<b>USE THE FOLLOWING FORM TO ADD SOMEONE TO THE MAILING LIST:</b><br/><br/>\n");
                writer.Write("<form action=\"mailingmgr.aspx\" method=\"post\" id=\"Form3\" name=\"Form3\">\n");
                writer.Write("<b>Add an E-Mail to Mailing List:</b> <input maxLength=\"100\" size=\"30\" name=\"AddEMail\" value=\"\">\n");
                writer.Write("&nbsp;&nbsp;<input class=\"normalButtons\" type=\"submit\" value=\"Add\" name=\"submit\">\n");
                writer.Write("</form>");
                writer.Write("</div>");
            }
    
        }
    }
    Any kind of guidance would be appreciated, I have a feeling it is just one mistyped letter somewhere. For some reason my COUNT() is not passing the information or it is just not getting to where the s array is being set. Therefore when it gets to:

    Code:
    String ToThisPerson = s[i];
    s is empty...