Umbraco-编辑器创建内容时,向管理员发送电子邮件通知

问题描述 投票:1回答:2

有可能吗?我是管理员。我想在编辑者(或作者或有权访问的人)创建某些内容(例如在“新闻”文档类型中输入“新闻”)时通过电子邮件收到通知。如何?我使用Umbraco 7.5

email notifications umbraco
2个回答
2
投票

您需要编码到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
            }
        }
    }
}

0
投票

您可以通过创建一些事件处理程序来编写自己的自定义代码,这是@wingyip的建议,或者您可以使用内置的Umbraco通知功能。

有关第二个内置选项,请在on this post处查看所有步骤。

© www.soinside.com 2019 - 2024. All rights reserved.