Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,



for now am binding only 1 record to email template,if the query returns 5 i want to bind 5 records ,if the query returns more than 10 i want to bind top 10 records and i want to include design to those records with anchor tags how can i solve this.Please suggest me
Posted
Comments
SRS(The Coder) 10-Aug-14 23:45pm    
can you please share your current code how you are doing for the single record ?
Accordingly we may suggest something.
Member 10226004 10-Aug-14 23:55pm    
foreach (var result in locationresult)
{
var getcountryid = context.Jobs.FirstOrDefault(n => n.Id == result.Id);
int countryid = getcountryid.CountryId;
var countryname = context.MasterCountries.FirstOrDefault(n => n.Id == countryid);

var template = context.EmailTemplates.FirstOrDefault(n => n.Name == "SendDailyAlerts");
var templateid = template.Id;
//string Subject=template.Subject;
var valuesList = new Hashtable
{
{"TotalCount",count},
{"Title", result.Title},
{"CompanyName",result.CompanyName},
{"LocationName",result.LocationName},
{"CountryName",countryname.Description},
{"Keyword",keyword},
{"Location",location},
{"Server Url",keyword+"-jobs-in-"+location+".aspx"},
{"Base Url","Home.aspx"},

//{"Salary",}
//{"Currency",salary.MasterCurrencyType.Symbol}

};
string baseUrl = "www.hostname.com/";
Program url = new Program();
string applyjob = Path.Combine(baseUrl, url.JobsUrlGenerator(result.Id));
valuesList.Add("Generate Url", applyjob);
var msg = new MailMessage();
string fromUserName = System.Configuration.ConfigurationManager.AppSettings["FromUserName"];
string userName = System.Configuration.ConfigurationManager.AppSettings["FromEmailjobs"];
string password = System.Configuration.ConfigurationManager.AppSettings["FromEmailPassword"];
string smtpAddress = System.Configuration.ConfigurationManager.AppSettings["SMTPAddress"];
int smtpPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SMTPPort"]);
bool enableSsl = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["EnableSsl"]);
string body = url.LoadTemplate(template.TemplateText, valuesList);
//SnovaUtil.SendEmail(template.Subject, body, user.EmailAddress);
url.SendEmail(template.Subject, body, mailid);
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900