我有一个表,我想从一列(mailid)中检索所有值。在表中有两列可用,即id和mailid。 我想向本栏中邮件ID可用的所有人发送邮件。
mstEmpAdmin m = new mstEmpAdmin();
var m2=(from e in db.mstEmpAdmins
select new
{
txtEmpAdminEmailId = e.txtEmpAdminEmailId,
});
CustomMailService mail = new CustomMailService();
string Subject = "Domestic Travel Request";
string Body = "Hi Sir/Madam,My ";
mail.Mail(m2,Subject, Body);
形成上面的代码,它在最后一行显示错误,我在想的是我将邮件ID存储在一个对象中,然后我将在发送邮件时传递该对象。
我能这样做吗?对此有何解决方案?
答案 0 :(得分:1)
我得到了输出。
List<mstEmpAdmin> adminlist = (from st in db.mstEmpAdmins
select st).ToList();
foreach (var item in adminlist)
{
string Subject = "Request for Business Card";
string Body = "Hello Sir/Madam ," + "\n" + " " + bc.txtFirstName + " " + "You have requested for Business Card" + " " + "Total no of Quantity :" + bc.intQuantity + " ";
CustomMailService mail = new CustomMailService();
mail.Mail(item.txtEmpAdminEmailId, Subject, Body);
}