2015-11-24 30 views
0

我想發送一封郵件,並使用IsBodyHtml讓我編輯郵件的外觀。我必須在其上放置一個鏈接,然後使用Parameter和id。我如何將這個包含在href中?在HTML鏈接上使用參數

這是我的例子與查詢字符串參數HREF的

string body = "<table><tr><td>Please be informed that your employee <b>" + Session["Userfull"] + "</b> wants to send the no <b>" + id + " </b>. <br /> Please see attached the <b>" 
     + "<a href=\'http://myproject/myproject.aspx'>" + "?Parameter=" + id 
     +" SF </a></b>.<br /><br /></td> </tr><tr><td>" + 
     "If you need more details <b>" + Session["User"] + "</b>.</td></tr> </table>"; 

回答

0

查詢字符串應該是鏈接的一部分。另外我會推薦使用字符串格式,以便代碼看起來乾淨。請在下方找到修改後的代碼

string bodyFormat = "<table><tr><td>Please be informed that your employee <b>{0}</b> wants to send the no <b>{1}</b>. <br /> Please see attached the <b><a href=\'http://myproject/myproject.aspx?Parameter={1}'> SF </a></b>.<br /><br /></td> </tr><tr><td>If you need more details <b>{2}</b>.</td></tr> </table>"; 
string body = string.Format(bodyFormat, Convert.ToString(Session["Userfull"]), id, Convert.ToString(Session["User"])); 
0

http://myproject/myproject.aspx?param1=1&param2=2&param3=3 

好像你有字符串連接想通了,所以只要你的查詢字符串參數追加到您的錨點href。