我创建了一个事件接收器,可以在添加项目时触发电子邮件。在此事件中,接收者电子邮件将发送给员工。在电子邮件内容中,我想提供一个链接,以便员工可以直接访问该网站。但在我的代码中我遇到了一些问题。这是我的代码
public string MailMsgBody_WU(string MailTo, SPItemEventProperties IERProperties)
{
string MMsgBody = "";
System.Diagnostics.Debug.WriteLine("Travel Request-MailMsgBody(): Begin");
try
{
MMsgBody += "<table>";
MMsgBody += "<tr><td>Hi,</td></tr>";
MMsgBody += "<tr><td><br></br></td></tr>";
MMsgBody += "<tr><td> New Calendar Item Event" + IERProperties.ListTitle + " has been added into learning portal.</td></tr>";
MMsgBody += "<tr><td><br></br></td></tr>";
MMsgBody += "<tr><td>Please click on the following link to view the details.</td></tr>";
MMsgBody += "<tr><td><br></br></td></tr>";
MMsgBody += "<tr><td><a href=" + http://tri02sharepoint:47709/Lists/Learning%20Calendar/calendar.aspx + ">Click Here</a></td></tr>";
MMsgBody += "<tr><td><br></br></td></tr>";
MMsgBody += "<tr><td><br></br></td></tr>";
MMsgBody += "<tr><td>Thanks,</td></tr>";
MMsgBody += "<tr><td>Learning Team</td></tr>";
MMsgBody += "</table>";
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Travel Request-MailMsgBody(): End" + ex.Message.ToString());
}
return MMsgBody;
}
我收到了错误
MMsgBody += "<tr><td><a href=" + http://tri02sharepoint:47709/Lists/Learning%20Calendar/calendar.aspx + ">Click Here</a></td></tr>";
http://&lt; ----这是错误
这些是错误
错误1无效的表达式术语':'
错误2;预计
错误3;预期
答案 0 :(得分:0)
你不能这样做:
MMsgBody += "<tr><td><a href=" + http://tri02sharepoint:47709/Lists/Learning%20Calendar/calendar.aspx + ">Click Here</a></td></tr>";
您基本上是在C#代码中调用名为“http:// tri02sharepoint ...”的函数/字段/成员,这显然不存在。
你应该这样做:
MMsgBody += "<tr><td><a href=\"http://tri02sharepoint:47709/Lists/Learning%20Calendar/calendar.aspx\">Click Here</a></td></tr>";
您需要转义特殊字符,例如“,然后使用 \ 进行转义。