我遇到以下错误:
类型' System.Web.HttpException'的第一次机会异常发生在System.Web.dll
其他信息:" SendUsing"配置值无效。
以下是我的C#代码:
public void getdata()
{
lbl_errorDob.Visible = false;
lbl_wishes.Visible = false;
foreach (GridViewRow gvr in Employeedob.Rows)
{
if (((CheckBox)gvr.FindControl("CheckBox2")).Checked == true)
{
value = "Success";
Label lb = (Label)gvr.FindControl("lbl_Email");
Label Name = (Label)gvr.FindControl("lbl_Ename");
MailMessage mailMsg = new MailMessage();
mailMsg.BodyFormat = MailFormat.Html;
string strBody = "";
string image = "http://xyzdotcom/images/bg_login.gif";
strBody = "<html><body background-repeat:no-repeat;\" > ";
strBody = strBody + "<br><br>";
strBody = strBody + "<table width='600' align='center'><tr><td> If you are not able to view this mailer properly,please <a href='http://xyzdotcom/birthdaywishes.html?Name=" + Name.Text + "&from=" + Session["EmpName"].ToString() + "'>click here</a><td><tr><table>";
strBody = strBody + "<br><br>";
mailMsg.From = Session["EmailId"].ToString();
// mailMsg.From = System.Configuration.ConfigurationManager.AppSettings["AdminEmailAddress"];
mailMsg.To = lb.Text;
mailMsg.Subject = "MANY MORE HAPPY RETURNS OF THE DAY";
mailMsg.Body = strBody;
SmtpMail.Send(mailMsg);
lbl_wishes.Visible = true;
lbl_errorDob.Visible = false;
}
else
{
if (value == "")
{
lbl_errorDob.Visible = true;
lbl_wishes.Visible = false;
}
}
}
}
protected void lnkbtn_SendMyWishes_Click(object sender, EventArgs e)
{
getdata();
}
我使用了以下名称空间:
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Mail;