email - Umbraco - 当编辑创建内容时向管理员发送电子邮件通知
问题描述
可能吗?我是管理员。我想在编辑(或作家或有权访问的人)创建一些内容(例如在新闻文档类型中输入一些新闻)时通过电子邮件收到通知。如何?我使用 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
}
}
}
}
推荐阅读
- ios - 比较两个 Any 值
- typescript - AWS 节点 SDK 没有 HttpClient
- javascript - 您如何在 2019 年/之后访问移动浏览器 web 应用程序中的运动传感器(加速度计、陀螺仪)?为什么它不再起作用?
- winapi - 如何使用 Rust 和 winapi crate 在 Windows 中创建事件订阅?
- sql - 日期范围男性女性的 SQL 查询
- javascript - 我的代码可以使用和不使用函数参数,我不明白为什么:
- python - 为什么 multiprocessing.Queue() 不起作用但 Manger.Queue() 在将队列对象传递给 multiprocessing.Pool 的情况下起作用
- android - 如何以编程方式更改片段的语言?
- c# - 如何在单元格点击事件中将日期格式转换为 yyMMdd?
- react-native - React Navigation 多个堆栈配置