Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Add Unsubscribe link to Dynamic Newsletter View modes: 
User avatar
Member
Member
Mercer - 7/3/2010 2:30:48 PM
   
Add Unsubscribe link to Dynamic Newsletter
Is it possible to add an unsubscribe newsletter link to a dynamic newsletter generated from a web page? I have tried adding a static HTML web part on the page and entering {%UnsubscribeLink%} without success. It appears I can add the Unsubscribe web part, but this requires the user to enter an email address. Also, how does that prevent someone from unregistering someone else? I have also tried using a standard newsletter and inserting an iFrame to my page. (The Iframe doesn't get included in the newsletter when sent.) Any suggestions? Thank you.

Michael

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 7/6/2010 9:46:34 AM
   
RE:Add Unsubscribe link to Dynamic Newsletter
Hello,

You can't add a context macro, because there is no context, from which it gets it's data. The only way is to use the unsubscription webpart. The standard approach for unsubscribing is to enter the e-mail. There is no prevention for unsubscribing someone else.

Best regards,
Boris Pocatko

User avatar
Member
Member
Mercer - 7/6/2010 12:00:52 PM
   
RE:Add Unsubscribe link to Dynamic Newsletter
Is there a way to include web content into an email template? We are looking to replace Constant Contact and would like to email current news items that are posted on the web. We have created a page that lists announcements documents which are sorted and set to automatically expire. Each week we email this list to all subscribers. One of our requirements is to include an unsubscribe link vs. an edit box. This helps us comply with the CAN-SPAM Act. Any suggestions? Thank you.

Michael

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 7/8/2010 2:52:55 AM
   
RE:Add Unsubscribe link to Dynamic Newsletter
Hello,

The only way to achieve this is to use a custom macro which will retrieve the given content from the site.

Best regards,
Boris Pocatko

User avatar
Member
Member
Mercer - 7/10/2010 2:56:44 PM
   
RE:Add Unsubscribe link to Dynamic Newsletter
Thanks for the suggestion to use a custom macro. I created the following custom marco to pull contents from a blog post. (Not very generic, but it works.)


switch (expression.ToLower())
{
case "gethtml":

// used to build entire input
StringBuilder sb = new StringBuilder();

// used on each read operation
byte[] buf = new byte[8192];

// prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://localhost/cmspages/news.aspx");

// execute the request
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();

// we will read data via the response stream
Stream resStream = response.GetResponseStream();

string tempString = null;
int count = 0;

do
{
// fill the buffer with data
count = resStream.Read(buf, 0, buf.Length);

// make sure we read some data
if (count != 0)
{
// translate from bytes to ASCII text
tempString = Encoding.ASCII.GetString(buf, 0, count);

// continue building the string
sb.Append(tempString);
}
}
while (count > 0); // any more data to read?

// print out page source
Console.WriteLine(sb.ToString());


result = sb.ToString();
break;
}



The following is the code for news.aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="News.aspx.cs" %>

<cms:cmsrepeater ID="BannerRepeater" runat="server" ClassNames="CMS.BlogPost"
TransformationName="CMS.BlogPost" SelectedItemTransformationName="CMS.BlogPost.BlogEmail" SelectOnlyPublished="true"
Path="/Announcements/Blogs/%"></cms:cmsrepeater>



Finally, I used the following in the transform to display the full path to the BlogPostTeaser image. This ensures the email message render with the full path. Maybe there is a better way to ensure emails link to the absolut image URL.


<%# IfEmpty(Eval("BlogPostTeaser"), "", GetImageByUrl("http://localhost/cmspages/GetFile.aspx?guid=" + Eval("BlogPostTeaser"))) %>


Now I can insert news items from blog posts into a newsletter and include the unsubscribe link.


User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 7/13/2010 8:17:27 AM
   
RE:Add Unsubscribe link to Dynamic Newsletter
Hello,

Thank you for posting your solution. It will certainly help other users.

Best regards,
Boris Pocatko