1

我创建了一个事件接收器,以在添加项目时触发电子邮件。在此事件中,接收器电子邮件将发送给员工。在电子邮件内容中,我想提供一个链接,以便员工可以直接访问该网站。但在我的代码中我遇到了一些问题。这是我的代码

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:// <---- 这里是错误

这些是错误

错误 1 ​​无效的表达式术语 ':'
错误 2 ; 预期
错误 3;预期的

4

1 回答 1

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>";

您需要转义特殊字符,例如",您可以使用\.

于 2012-02-06T13:54:59.863 回答