我找到了解決方案。這裏使用了一段代碼。
在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