我找到了解决方案。这里使用了一段代码。
在GridView中,对于份额超链接我用:
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# DataBinder.Eval(Container.DataItem,"FileName","Share.aspx?FileName={0}") %>'
Text="Share"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
在share.aspx页
string datalink;
protected void Page_Load(object sender, EventArgs e)
{
this.TextBox2.Text = Request.QueryString[0];
datalink = this.TextBox2.Text;
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
// Create the mail message
string strFrom = "[email protected]";
string strTo = TextBox1.Text;
string strCC = TextBox3.Text;
string strSubject = "Document shared";
string strMsg = " The document has been shared with you. Please check the attachment.";
string myPath = @"C:\Visual Studio 2008\Data\";
MailMessage objMailMsg = new MailMessage(strFrom, strTo);
objMailMsg.BodyEncoding = Encoding.UTF8;
objMailMsg.Subject = strSubject;
objMailMsg.Body = strMsg;
objMailMsg.CC.Add(strCC);
Attachment at = new Attachment(myPath + datalink);
objMailMsg.Attachments.Add(at);
objMailMsg.Priority = MailPriority.High;
objMailMsg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.EnableSsl = true;
smtp.Send(objMailMsg);
}
catch (Exception ex)
{
throw ex;
}
}
什么是你的问题?你有什么尝试? – Oded
我的问题是,当我点击第一行的共享时,它应该要求我写邮件,一旦我写它,老虎文件应通过电子邮件发送到写的地址。我怎样才能做到这一点? – user662417
好的,但你的问题到底是什么?我如何区分哪个行被选中?或者我如何发送电子邮件?什么是具体问题? – dasheddot