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.