I have the following code which is used to send a newsletter
public string UpdateHtml()
{
System.IO.StreamReader myFile = new System.IO.StreamReader(Server.MapPath("RedRibbonDeals/Deals.html"));
string s = myFile.ReadToEnd();
myFile.Close();
DataTable dt = SqlDataAccess.ExecuteDataset(SqlDataAccess.ConnectionString, CommandType.StoredProcedure, "spEXTGetDealsOfTheWeekNewsletter").Tables[0];
StringBuilder sb = new StringBuilder();
StringBuilder html = new StringBuilder();
for (int i = 0; i < dt.Rows.Count; i++)
{
if (i <= 2)
{
int j = i + 1;
s = s.Replace("http://!!RR IMG" + j + " RR!!", "http://212.78.89.87/adminp4/admin/offerimages/" + dt.Rows[i]["ItemID"].ToString() + ".jpg");
s = s.Replace("!!RR ITEMID" + j + " RR!!", dt.Rows[i]["ItemID"].ToString());
s = s.Replace("!!RR DEALTITLE" + j + " RR!!", dt.Rows[i]["ItemName"].ToString()); //.Substring(0, 0));
s = s.Replace("!!RR DEALDESCRIPTION" + j + " RR!!", dt.Rows[i]["Description"].ToString());
s = s.Replace("!!RR RRActualNow" + j + " RR!!", dt.Rows[i]["RRActual"].ToString());
s = s.Replace("!!RR RRRRPWas" + j + " RR!!", dt.Rows[i]["RRRRP"].ToString());
s = s.Replace("!!RR enddateENDDATE" + j + " RR!!", String.Format("{0:M/d/yyyy}", dt.Rows[i]["enddate"]));
}
}
sb.Append(s);
if (dt.Rows.Count > 3)
{
int x, y;
x = dt.Rows.Count;
y = x - 3;
int rowCnt;
if (y % 3 == 0)
{
rowCnt = y / 3;
}
else
{
rowCnt = y / 3 + 1;
}
int cellCtr;
int cellCnt = 0;
html.Append("<table class='itemSet3' width='650' >");
if (dt.Rows.Count > 3)
{
int i = 3;
for (int rowCtr = 1; rowCtr <= rowCnt; rowCtr++)
{
html.Append("<tr valign='top'>");
if (y > 3)
{
cellCnt = 3;
y = y - 3;
}
else
{
cellCnt = y;
}
if (i < dt.Rows.Count)
{
for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++)
{
html.Append("<td>");
html.Append("<table cellpadding='10'>");
html.Append("<tr class='image' valign='top'>");
html.Append("<td>");
html.Append("<a target='_blank' href='http://www.redribbon.ie/offer/offer-detail.aspx?OfferID=" + dt.Rows[i]["ItemID"].ToString() + "'" + "style='color:#333333; text-decoration:none;'>");
//html.Append("<a target='_blank' href='http://www.redribbon.ie/default.aspx?ID=" + dt.Rows[i]["ItemID"].ToString() + "'" + "style='color:#333333; text-decoration:none;'>");
html.Append("<font style='font-family:Arial, Helvetica, sans-serif; font-size:13px; font-weight:bold; color:#317ca6;' face='Arial, Helvetica, sans-serif'>");
if(dt.Rows.Count <6)
{
html.Append("<img border='1' src='http://212.78.89.87/adminp4/admin/offerimages/" + dt.Rows[i]["ItemID"].ToString() + ".jpg' width='255' height='150'></font></a>");
}
else
{
html.Append("<img border='1' src='http://212.78.89.87/adminp4/admin/offerimages/" + dt.Rows[i]["ItemID"].ToString() + ".jpg' width='180' height='120'></font></a>");
}
html.Append("</td>");
html.Append("</tr>");
html.Append("<tr class='headline' valign='top'>");
html.Append("<td>");
html.Append("<h2>" + dt.Rows[i]["ItemName"].ToString() + "</h2>");
html.Append("</td>");
html.Append("</tr>");
html.Append("<tr class='priceTag' valign='top'>");
html.Append("<td>");
html.Append("<table class='priceTag' cellpadding='0' cellspacing='0' background='http://www.redribbon.ie/images/dow/img/priceTag.gif' width='187' height='61'>");
html.Append("<tr valign='top'>");
html.Append("<td width='64' rowspan='2' class='now'>");
html.Append("<h2>Now</h2>");
html.Append("<h3>€" + dt.Rows[i]["RRActual"].ToString() + "</h3></td>");
html.Append("<td width='61' height='40' class='was'>");
html.Append("<h2>Was</h2>");
html.Append("<h3>€" + dt.Rows[i]["RRRRP"].ToString() + "</h3>");
html.Append("</td>");
html.Append("<td width='60'>");
html.Append("<a href=''></a>");
html.Append("</td>");
html.Append("</tr>");
html.Append("<tr valign='top'>");
html.Append("<td colspan='3' class='end'>");
html.Append("<p>Deal Ends: <strong>" + String.Format("{0:M/d/yyyy}", dt.Rows[i]["enddate"]) + "</strong></p>");
html.Append("</td>");
html.Append("</tr>");
html.Append("</table>");
html.Append("</td>");
html.Append("</tr>");
html.Append("</table>");
string test = html.ToString();
i = i + 1;
}
}
}
html.Append("</td>");
html.Append("</tr>");
html.Append("</table>");
}
}
sb.Append(html);
sb.Append("<table cellpadding='0' cellspacing='0' width='100%'>");
sb.Append("<tr valign='top'>");
sb.Append("<td align='center'>");
sb.Append("<p>You have received this email because you have subscribed to the Redribbon.ie Newsletter.<br/>You can unsubscribe from the Redribbon.ie Newsletter via <a target='_blank' href='http://www.redribbon.ie/about/unsubscribe.aspx' style='color:#ffffff;'><font
style='color: #F00;'>this link</font></a>.</p>");
sb.Append("</td>");
sb.Append("</tr>");
sb.Append("</table>");
sb.Append("<!-- // End of Module: 3 Item Row \\ -->");
sb.Append("<!-- // Begin Template Footer \\ -->");
sb.Append("<table border='0' cellpadding='10' cellspacing='0' width='650' id='templateFooter'>");
sb.Append("<tr>");
sb.Append("<td valign='top' class='footerContent'>");
sb.Append("<!-- // Begin Module: Standard Footer \\ -->");
sb.Append("<table border='0' cellpadding='10' cellspacing='0' width='100%'>");
sb.Append("<tr>");
sb.Append("<td colspan='2' valign='middle' id='social'>");
sb.Append("<div mc:edit='std_social'>");
sb.Append("<a href='https://www.facebook.com/redribbon.ie'>friend on Facebook</a> | <a href='https://twitter.com/RedRibbon_Gifts'>follow on Twitter</a> | <a href='mailto:address@domain.com'>forward to a friend</a> ");
sb.Append("</div>");
sb.Append("</td>");
sb.Append("</tr>");
sb.Append("<!--");
sb.Append("<tr>");
sb.Append("<td valign='top' width='350'>");
sb.Append("<div mc:edit='std_footer'>");
//sb.Append("<em>Copyright © *|CURRENT_YEAR|* *|LIST:COMPANY|*, All rights reserved.</em>");
sb.Append("<em>Copyright © 2013 Redribbon, All rights reserved.</em>");
//sb.Append("<br />");
//sb.Append("*|IFNOT:ARCHIVE_PAGE|* *|LIST:DESCRIPTION|*");
sb.Append("<br />");
sb.Append("<strong>Our mailing address is:</strong>");
sb.Append("<br />");
//sb.Append("*|HTML:LIST_ADDRESS_HTML|**|END:IF|*");
sb.Append("info@redribbon.ie");
sb.Append("</div>");
sb.Append("</td>");
sb.Append("<td valign='top' width='190' id='monkeyRewards'>");
//sb.Append("<div mc:edit='monkeyrewards'>");
//sb.Append("*|IF:REWARDS|* *|HTML:REWARDS|* *|END:IF|*");
//sb.Append("</div>");
sb.Append("</td>");
sb.Append("</tr>");
sb.Append("-->");
sb.Append("<tr class='contact'>");
sb.Append("<td width='400'>");
sb.Append("<p>70 Leeson Street Upper, Dublin 4</p>");
sb.Append("<p>Monday to Friday 9am - 5.30pm (excluding Bank Holidays)</p>");
sb.Append("</td>");
sb.Append("<td>");
sb.Append("<h2> </h2>");
sb.Append("<p><b>Phone:</b> +353 0818 240 073</p>");
sb.Append("<p><b>Fax:</b> +353 1 6675381</p>");
sb.Append("<p><b>Web:</b> www.redribbon.ie</p>");
sb.Append("<p><b>Email:</b> info@redribbon.ie</p>");
sb.Append("</td>");
sb.Append("</tr>");
sb.Append("<tr class='partners'>");
sb.Append("<td colspan='2'>");
//sb.Append("<img src='RedRibbonDeals/Images/SpongeLogo-Small.png' />");
//sb.Append("<img src='http://redribbon.ie/RedRibbonDeals/Images/SpongeLogo-Small.png' />");
sb.Append("<img src='http://212.78.89.87/adminp4/admin/Images/SpongeLogo-Small.png' />");
sb.Append("<p>We are delighted to announce our partnership with Sponge It. It‚s simple – complete research with Sponge It and get Red Ribbon vouchers. To get started, <a href=' http://surveyanalytics.com/t/ACFGkZNuTI'>click here</a>.</p>");
sb.Append("</td>");
sb.Append("</tr>");
sb.Append("</table>");
sb.Append("</td>");
sb.Append("</tr>");
sb.Append("</table>");
sb.Append("<!-- // End Module: Standard Footer \\ -->");
sb.Append("<!-- End of footer -->");
sb.Append("<table cellpadding='0' cellspacing='0' width='650' height='100'>");
sb.Append("<tr>");
sb.Append("<td class='copyright'>");
sb.Append("<img src='http://redribbon.ie/App_Themes/Default/Images/rr-logo-small.png' alt='RedRibbon'>");
sb.Append("<p>Copyright 2012 RedRibbon. All Rights Reserved</p>");
sb.Append("</td>");
sb.Append("</tr>");
sb.Append("</table>");
string shtml = sb.ToString();
shtml = shtml.Replace("!!RR DATE RR!!", DateTime.Now.ToShortDateString());
shtml = shtml.Replace("!!RRLinkRR!!", "http://www.redribbon.ie/about/MailinBrowser.aspx");
shtml = shtml.Replace("�", "");
return shtml;
}
protected void btnconvert_Click(object sender, EventArgs e)
{
//litEmailPreview.Text = UpdateHtml();
txtEmailPreview.Text = UpdateHtml();
}
Now some of the images are not coming in the mail and also the styling is a bit different but when the same thing is viewed in a browser its perfect .
I tried to rightclick on the email body and download pictures but still its not working any ideas