锚标记在事件接收器中不起作用

发布于 2025-01-03 01:59:31 字数 2067 浏览 2 评论 0原文

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

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 += "点击此处< ;/td>";

http:// <---- 这里是错误

这些是错误

错误 1 ​​无效的表达式术语“:”
错误2;预计
错误3;预计

I have created an event receiver to trigger an e-mail whenever an item was added.in this event receiver email gets deliverd to the employee. In the e-mail content i would like to give a link so that the employee can go to the web site directly. but in my code i am facing some problem . here is my code

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

i am getting the error in
MMsgBody += "<tr><td><a href=" + http://tri02sharepoint:47709/Lists/Learning%20Calendar/calendar.aspx + ">Click Here</a></td></tr>";

http:// <---- here is the Error

These are the errors

Error 1 Invalid expression term ':'
Error 2 ; expected
Error 3 ; expected

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

つ可否回来 2025-01-10 01:59:31

你不能这样做:

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

您需要转义 " 等特殊字符,并使用 \ 来实现。

You can't do this:

MMsgBody += "<tr><td><a href=" + http://tri02sharepoint:47709/Lists/Learning%20Calendar/calendar.aspx    + ">Click Here</a></td></tr>";

You are basically trying to call a function/field/member called "http://tri02sharepoint..." within your C# code, which obviously does not exist.

You should do this instead:

MMsgBody += "<tr><td><a href=\"http://tri02sharepoint:47709/Lists/Learning%20Calendar/calendar.aspx\">Click Here</a></td></tr>";

You need to escape special characters like " and you do that with a \.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文