列表文件夹上的 Sharepoint 警报

发布于 2024-08-07 22:05:20 字数 831 浏览 0 评论 0 原文

我想以编程方式向共享点列表内的文件夹添加警报。我已经找到了如何为列表设置警报,这非常有效。

有人可以帮助我了解如何为列表中的特定文件夹设置警报吗?

下面是我当前拥有的代码,仅将警报设置为列表。

    using (SPSite site = new SPSite("http://site/"))
{
using (SPWeb web = site.OpenWeb())
{
    SPUser user = web.SiteUsers["domain\\user"];
SPAlert newAlert = user.Alerts.Add();
newAlert.AlertType = SPAlertType.List;
newAlert.List = web.Lists["Documents"];
newAlert.EventType = SPEventType.All;
newAlert.AlertFrequency = SPAlertFrequency.Immediate;
//passing true to Update method will send alert confirmation mail
newAlert.Update(true);
}
}

非常感谢您的帮助

此问题已解决!请参阅下面我的帖子和链接 - 请参阅 - 链接

I would like to programatically add alert to folders inside a sharepoint list. I have found how to set alerts to a list and this works perfect.

Could someone please help me on how to set alerts to a specific folder which is inside a list.

Below is the code i currently have which sets alerts only to the list.

    using (SPSite site = new SPSite("http://site/"))
{
using (SPWeb web = site.OpenWeb())
{
    SPUser user = web.SiteUsers["domain\\user"];
SPAlert newAlert = user.Alerts.Add();
newAlert.AlertType = SPAlertType.List;
newAlert.List = web.Lists["Documents"];
newAlert.EventType = SPEventType.All;
newAlert.AlertFrequency = SPAlertFrequency.Immediate;
//passing true to Update method will send alert confirmation mail
newAlert.Update(true);
}
}

Your help will be much appreciated

THIS QUESTION IS RESOLVED! PLEASE SEE MY POST BELOW WITH THE LINK - SEE - LINK

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

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

发布评论

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

评论(2

蓝眸 2024-08-14 22:05:20

这是不可能的,但在谷歌搜索后我发现了一个有趣的可能性,请查看 Mike Walsh 在 这篇文章,它需要在文件夹中创建一个视图,然后将警报附加到该视图。

That's not possible out of the box, but after googling I found an interesting possibility though, check out Mike Walsh's answer on this post, it entails creating a view in the folder and then attaching the alert to that view.

因为看清所以看轻 2024-08-14 22:05:20

您需要使用 With 更新该行

newAlert.List = web.Lists["Documents"];

SPFolder fldr = web.GetFolder("/ListName/FolderName");
newAlert.Item=fldr.Item;

请注意,文件夹也是另一个项目。

You need to update the line with

newAlert.List = web.Lists["Documents"];

With

SPFolder fldr = web.GetFolder("/ListName/FolderName");
newAlert.Item=fldr.Item;

Also note that Folder is also another item.

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