我希望有人可以帮助我解决这个问题。此电子邮件功能的目的是向电子邮件正文列出的个人发送电子邮件,并在电子邮件正文中附加特定的URL字符串。我能够从GridView发送多封电子邮件,并在电子邮件正文的URL中传递当前查询字符串。所以一切工作都很好。我有一个无法解决的挑战。我想在URL中包含GridView中对应的电子邮件ID。这里是我当前的URL看起来怎么样: //MyHost/BCA/Users/QMR.aspx?Post_ID=303从GridView发送多个电子邮件
如果我的gridview的是这样的:
ID Name Email Post_ID
-------------------------------------------------------------------
32 Mike [email protected] 303
然后我想包括相应的ID为这封电子邮件在我的网址,如下所示,并能够将URL发送给该用户: //MyHost/BCA/Users/QMR.aspx?Post_ID=303 & ID = 32
感谢
这里是我的代码:
protected void btnSendEmail_Click(object sender, EventArgs e)
{
MailMessage mailMessage = new MailMessage();
foreach (GridViewRow gr in GridView1.Rows)
{
CheckBox cb = (CheckBox)gr.FindControl("chkItem");
if (cb.Checked)
{
mailMessage.To.Add(new MailAddress(GridView1.DataKeys[gr.RowIndex]["Assigned_To"].ToString()));
mailMessage.From = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["fromEmailAddress"]);
mailMessage.Priority = System.Net.Mail.MailPriority.High;
//Text/HTML
mailMessage.IsBodyHtml = false;
string mySubURI= HttpContext.Current.Request.Url.AbsoluteUri.ToString().Replace("Test.aspx", "QMR.aspx");
mailMessage.Body = "Hello, Please see this link" + mySubURI;
mailMessage.Subject = "My Email Test";
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
try
{
smtpClient.Send(mailMessage);
//Response.Write("<B>Email Has been sent successfully.</B>");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
这是公共站点还是内联网? – IrishChieftain