i have send mail through smtp server. can able send single values. but, want send list<> values message body in table format or other structure. include code following :
mailmessage mailobj = new mailmessage("abc@gmail.com", "xyz@gmail.com", "reg : send mail", "emp name :" + "emp1" + environment.newline + "date : " + mon + "date : " + fri); smtpclient smtpserver = new smtpclient("smtp.gmail.com", ***); smtpserver.host = "smtp.gmail.com"; smtpserver.enablessl = true; smtpserver.timeout = 200000; smtpserver.credentials = new system.net.networkcredential("asd@gmail.com", "******"); smtpserver.send(mailobj); i have list of values follows :
list<timesheetvalues> mailbody = new sampledao().getdataformail(dt1, satdate); how can include list<> values body , send?
i try following :
list<timesheetvalues> msg = new list<timesheetvalues>(); string strmsg = ""; int n=1; foreach(var item in mailbody) { strmsg = strmsg + "<table><tr><td>" + n + "</td><td>" + item.project_name + "</td><td>" + item.task_name + "</td><td>" + item.notes + "</td><td>" + item.hrs_worked + "</td></tr></table>"; n++; } strmsg = strmsg + "</br>"; mailmessage mailobj = new mailmessage("abc123@gmail.com", "xyz123@gmail.com", "reg : timesheet", "emp name :" + "emp1" + environment.newline + "date : " + mon + "date : " + fri); mailobj.body = "emp name : " + "emp1" + environment.newline + "date : " + date2 + " date : " + date6 + environment.newline + strmsg; now records have tr td tags in records , not display table. how can acheive ?
can overcome this.. in advance...
if want read string list again, serialize better.
using newtonsoft.json; var json = jsonconvert.serializeobject(yourlist); mailobj.body = json; you can deserialize in other side:
list<string> g = jsonconvert.deserializeobject<list<string>>(body);
Comments
Post a Comment