Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Craig O'Mahony 364 posts 918 karma points
    Jul 27, 2015 @ 09:13
    Craig O'Mahony
    0

    Sending 'Newsletter' emails to subscribers

    Hi all,

    I'm after some advice really.....

    In my Umbraco back office I have a series of nodes (as usual) and I have a series of members, I also have a 'special' set of nodes in the content tree that are my categories. I've created a Multinode Tree Picker that targets these categories and this MNTP is associated to document types and the members group.

    What ultimately I'd like to 'get' all of the created/amended in the last seven days that is marked for sending out in the newsletter email and then send links for this content 'out' in an email to the members that have subscribed to the category.

    So what I thought that I would do is get a list of the content:

    IEnumerable<DynamicNode> alertList = new DynamicNode(-1).Descendants().Items.Where(x => DateTime.Parse(x.GetProperty("UpdateDate").Value) > last7 && x.HasProperty("umbracoNaviHide") && x.GetProperty("umbracoNaviHide").Value != "1" && x.HasProperty("includeInEAlerts") && x.GetProperty("includeInEAlerts").Value == "1" && x.HasProperty("eAlertCategories") && x.GetProperty("eAlertCategories").Value != "");
    

    Then get a list of all of the categories:

     IEnumerable<DynamicNode> myCategories = new DynamicNode(2396).Descendants();
    

    And then loop through the categories and then assign the each entry to a new list if the categories for the content node matches the category that's in the loop:

            //group the categories together (Somehow)
            foreach (var category in myCategories)
            { 
                foreach(var alert in alertList)
                {
                    //Should this alert be added to this category block?
                    if (alert.GetPropertyValue("eAlertCategories").Contains(category.Id.ToString()))
                    {
                        myEmailData.Add(new EmailBlock { alertCategory = category.Id, alertName = alert.GetPropertyValue("pageTitle"), alertURL = alert.NiceUrl });
                    }
                }
            }
    

    So hopefully (!) I'd end up with series of category 'blocks'.

    Then (I think) that I need to loop through the members and assign build up a string 'block' based upon what categories they are subscribed to and send the email.

    I think that I can do this but I'm after any advice really on whether there might be a better way of achieving what I'm after.

    Anyone spare a few minutes to throw some advice my way please?

    thanks, Craig

Please Sign in or register to post replies

Write your reply to:

Draft