I see some question closed by administrator with similar question. I will try to explain in detail the solution I'm looking for:
First I'm trying to develop a windows console application.
Sending frequency: monday to friday
How many users: from 5 to 20
Format of data: A table where rows are countries and columns different types of products and the cells represent the sale of that country-product
Limitation: Service users prefer not to use a pdf or excel or attachment of any type should be a html format possible to show in the body of mail
Currently I am creating the report almost artisan with something like:
.....
var myStringBuilder = new StringBuilder("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">");
myStringBuilder.Append("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">");
myStringBuilder.Append("</head><body>");
myStringBuilder.AppendLine();
myStringBuilder.Append("<table style=\"font-family: Calibri; text-align: right; font-size: x-small;\">");
myStringBuilder.AppendLine();
var header = new StringBuilder("<tr><th>a</th><th>CATEG1</th><th>CATEG2</th><th>CATEG3</th><th>CATEG4</th><th>TOTAL</th></tr>");
var line = new StringBuilder("<tr><td>a</td><td>b</td><td>c</td><td>z</td><td>e</td><td>f</td></tr>");
foreach (var a in _actuals)
{
line.Replace("a", a.CountryName);
if(a.Segment.ToLowerInvariant().Equals("categ1")) {
line.Replace("b", "[" + string.Format("{0:0,#}", a.LsvLcFact / 1000) + "]"); }
else if (a.Segment.ToLowerInvariant().Equals("categ2")) {
line.Replace("c", "[" + string.Format("{0:0,#}", a.LsvLcFact / 1000) + "]"); }
else if (a.Segment.ToLowerInvariant().Equals("categ3")) {
line.Replace("z", "[" + string.Format("{0:0,#}", a.LsvLcFact / 1000) + "]"); }
else {
line.Replace("e", "[" + string.Format("{0:0,#}", a.LsvLcFact / 1000) + "]"); }
}
.....
And in the class to send mail something like:
public void SendResumen(string subject ,StringBuilder content)
{
var oMsg = new MailMessage...;
... add users
oMsg.Subject = subject;
var mimeType = new ContentType("text/html");
var alternate = AlternateView.CreateAlternateViewFromString(content.ToString(), mimeType);
oMsg.AlternateViews.Add(alternate);
oMsg.IsBodyHtml = true;
var cli = Client();
cli.Send(oMsg);
}
Finally, I hope you understand what I'm doing and the question is: Is there a tool I can use to not generate as crafted the message body?