Umbraco - 当编辑器创建内容时向管理员发送电子邮件通知
Umbraco - when editor create content send email notification to admin
可能吗?
我是管理员。当编辑(或作家或任何有权访问的人)创建一些内容(例如,在新闻文档类型中输入一些新闻)时,我想通过电子邮件收到通知。
如何?
我使用 Umbraco 7.5
您需要编码到 Umbraco ContentService 事件中。
以下应该可以帮助您入门。每当发布项目时都会触发它。
尽管如此,请小心你的愿望。如果有人发布父节点及其所有子节点,您可能会收到一连串无用的电子邮件。
您还可以挂接其他事件,因此请参阅 https://our.umbraco.com/Documentation/Reference/Events/ContentService-Events-v7 上的文档。
using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Publishing;
using Umbraco.Core.Services;
namespace My.Namespace
{
public class MyEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ContentService.Published += ContentServicePublished;
}
private void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> args)
{
foreach (var node in args.PublishedEntities)
{
// Your code to send email here
}
}
}
}
您可以通过创建一些事件处理程序来编写自己的自定义代码,这是@wingyip 推荐的,或者您可以使用内置的 Umbraco 通知功能。
对于第二个内置选项,请在此处查看所有步骤on this post。
可能吗? 我是管理员。当编辑(或作家或任何有权访问的人)创建一些内容(例如,在新闻文档类型中输入一些新闻)时,我想通过电子邮件收到通知。 如何? 我使用 Umbraco 7.5
您需要编码到 Umbraco ContentService 事件中。
以下应该可以帮助您入门。每当发布项目时都会触发它。
尽管如此,请小心你的愿望。如果有人发布父节点及其所有子节点,您可能会收到一连串无用的电子邮件。
您还可以挂接其他事件,因此请参阅 https://our.umbraco.com/Documentation/Reference/Events/ContentService-Events-v7 上的文档。
using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Publishing;
using Umbraco.Core.Services;
namespace My.Namespace
{
public class MyEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ContentService.Published += ContentServicePublished;
}
private void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> args)
{
foreach (var node in args.PublishedEntities)
{
// Your code to send email here
}
}
}
}
您可以通过创建一些事件处理程序来编写自己的自定义代码,这是@wingyip 推荐的,或者您可以使用内置的 Umbraco 通知功能。
对于第二个内置选项,请在此处查看所有步骤on this post。