Newsletter module

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
3/12/2011 10:04:23 AM
Gravatar
Total Posts 32

Newsletter module

Are there any plan to add functionality in the near future to this module?

Reason i ask is simple i'm missing quite some functions like:

  • importing csv files and assigning to newsletters (conversion and initial setup)
  • newsletter statistics
  • localized unsubscribe
  • better styling support
  • custom fields

if there is nothing in the planning i want to use the standard module as basis to build the additional functions we've been using for years now as a seperate module (so it doesn't impact the core system) and donate it back so you can decide to replace current module or append or ...

peter

3/13/2011 12:27:08 PM
Gravatar
Total Posts 18439

Re: Newsletter module

there are planned improvements but I have no estimate on when it will happen.

If you'd like to contribute your code to the project for potential use of some parts of it that would be great. Please read the guidelines here for contributing:

http://www.mojoportal.com/contribute.aspx

You will also need to download the contribution agreement pdf (linked from the page above), sign it and mail it to us.

Best,

Joe

3/13/2011 3:58:36 PM
Gravatar
Total Posts 32

Re: Newsletter module

Hi Joe

Since there are planned enhancements on its way it will be difficult to keep things aligned.

Main thing i was missing for my clients is the ability to import a textfile with email addresses and assign them to one or more newsletters.

Created a simple pageI've copied the eLetter module and all pages and put everything in a new project.

Currently there is an ASPX page with a file upload for the importer and the code behind which is pretty simple.

i like simple to will just add the code here (watch for changed namespace because of project copy)

ASPX page

<%@ Page Title="" Language="C#" MasterPageFile="~/App_MasterPages/layout.Master" AutoEventWireup="true" CodeBehind="LetterImport.aspx.cs" Inherits="PraveMarketing.UI.LetterImport" %>

<asp:Content ContentPlaceHolderID="leftContent" ID="MPLeftPane" runat="server" />
<asp:Content ContentPlaceHolderID="mainContent" ID="MPContent" runat="server">

<div class="breadcrumbs">
<span id="spnAdmin" runat="server"><asp:HyperLink ID="lnkLetterAdmin" runat="server" CssClass="unselectedcrumb" />&nbsp;&gt;</span>
<asp:HyperLink ID="lnkThisPage" runat="server" CssClass="selectedcrumb" />
</div>

<asp:Repeater ID="rptLetters" runat="server">
<HeaderTemplate><ul class='simplelist newsletterlist'></HeaderTemplate>
<ItemTemplate>
<li>
<input type="checkbox" 
id='chk<%# DataBinder.Eval(Container.DataItem,"LetterInfoGuid").ToString() %>' checked="checked"
title='<%# DataBinder.Eval(Container.DataItem,"Title") %>' name='chk<%# DataBinder.Eval(Container.DataItem,"LetterInfoGuid").ToString() %>'  />
<label for='chk<%# DataBinder.Eval(Container.DataItem,"LetterInfoGuid").ToString() %>'><%# DataBinder.Eval(Container.DataItem,"Title") %></label>


</li>
</ItemTemplate>
<FooterTemplate></ul></FooterTemplate>
</asp:Repeater>
<div>
  <asp:FileUpload ID="FileUpload1" runat="server" /><br />
   <portal:mojoButton ID="BtnUpload" runat="server"  
        onclick="btnUploadAndImport_Click"  />
</div>
</asp:Content>
<asp:Content ContentPlaceHolderID="rightContent" ID="MPRightPane" runat="server" />
<asp:Content ContentPlaceHolderID="pageEditContent" ID="MPPageEdit" runat="server" />
 

 

CODE BEHIND


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Web.UI;
using System.Web.UI.WebControls;
using mojoPortal.Web.Framework;
using mojoPortal.Web.Editor;
using mojoPortal.Business;
using mojoPortal.Business.WebHelpers;
using mojoPortal.Net;
using Resources;
using mojoPortal.Web;
using System.IO;
using System.Text;


// resource
//  lnkLetterImportLink Import CSV file
namespace PraveMarketing.UI
{
    public partial class LetterImport : NonCmsBasePage
    {
        private SiteSettings siteSettings = null;
        private SubscriberRepository subscriptions = new SubscriberRepository();
        private List<LetterInfo> siteAvailableSubscriptions = null;
        protected string siteRoot = string.Empty;
   
        protected void Page_Load(object sender, EventArgs e)
        {
            BtnUpload.Text = Resource.BtnUploadText;
            BindList();
        }

        private void BindList()
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            siteRoot = SiteUtils.GetNavigationSiteRoot();
         
            siteAvailableSubscriptions = NewsletterHelper.GetAvailableNewslettersForCurrentUser(siteSettings.SiteGuid);
            if (siteSettings == null) { return; }
       
            if (siteAvailableSubscriptions == null) { return; }

            rptLetters.DataSource = siteAvailableSubscriptions;
            rptLetters.DataBind();
            if (rptLetters.Items.Count == 0) { this.Visible = false; }

        }

        protected void btnUploadAndImport_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string dataFolder = Server.MapPath(siteSettings.DataFolder);
                string fileName = "import.txt";
                string fullCleanedFileNameWithPath = dataFolder  + fileName;
                FileUpload1.SaveAs(fullCleanedFileNameWithPath);
                //read the file into a list of String and Subscribe them
               string[] emails = File.ReadAllLines(fullCleanedFileNameWithPath);
               foreach (string emailaddress in emails)
               { DoSubscribe(emailaddress); }

            }

        }
        private void DoSubscribe(string emailAddressToSubscribe)
        {
                foreach (LetterInfo available in siteAvailableSubscriptions)
                {
                    string controlID = "chk" + available.LetterInfoGuid.ToString();
                    if (Request.Params.Get(controlID) != null) //only found if checked
                    {
                        DoSubscribe(available, emailAddressToSubscribe);
                    }
                }
        }

        private void DoSubscribe(LetterInfo letter, string email)
        {
            LetterSubscriber s = subscriptions.Fetch(siteSettings.SiteGuid, letter.LetterInfoGuid, email);
            if (s == null)
            {
                s = new LetterSubscriber();
                s.SiteGuid = siteSettings.SiteGuid;
                s.EmailAddress = email;
                s.LetterInfoGuid = letter.LetterInfoGuid;
                    s.UseHtml = true;
                    s.UserGuid = new Guid();
                    s.IsVerified = true;
                s.IpAddress = SiteUtils.GetIP4Address();
                SiteUser siteUser = SiteUser.GetByEmail(siteSettings, email);
                //if user exist use userguid else guid.empte
                if (siteUser != null) { s.UserGuid = siteUser.UserGuid; }
                subscriptions.Save(s);
                LetterInfo.UpdateSubscriberCount(s.LetterInfoGuid);
            }
        }
    }
}

 

RESOURCE ENHANCEMENT

BtnUploadText Upload txt file

 You may use this in your next version.

My next step is to implement a detailed analysis so we can see who has received the eletter and who has read it using a simple handler with a 1px image added to the html message

 

peter

You must sign in to post in the forums. This thread is closed to new posts.