EasyNotice.Email
2.1.4
dotnet add package EasyNotice.Email --version 2.1.4
NuGet\Install-Package EasyNotice.Email -Version 2.1.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EasyNotice.Email" Version="2.1.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EasyNotice.Email" Version="2.1.4" />
<PackageReference Include="EasyNotice.Email" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EasyNotice.Email --version 2.1.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EasyNotice.Email, 2.1.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EasyNotice.Email@2.1.4
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EasyNotice.Email&version=2.1.4
#tool nuget:?package=EasyNotice.Email&version=2.1.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EasyNotice
Nuget包
| Package Name | Version | Downloads |
|---|---|---|
| EasyNotice.Core | ||
| EasyNotice.Dingtalk | ||
| EasyNotice.Email | ||
| EasyNotice.Feishu | ||
| EasyNotice.Weixin |
EasyNotice
这是一个基于.NET开源的消息通知组件,它包含了邮件通知、钉钉、飞书、企业微信通知,可以帮助我们更容易地发送程序异常通知!
功能介绍
- 支持[邮件]、[钉钉]、[飞书]、[企业微信]方式发送
- 支持自定义发送间隔,避免同样的异常频繁通知
- 傻瓜式配置,开箱即用
平台支持
- SMTP邮箱
- 钉钉群机器人
- 飞书群机器人
- 企业微信群机器人
文档资料
项目接入
项目接入提供了以下发送方式的Demo:邮件通知、钉钉通知、飞书、企业微信通知
1. 邮件通知
邮件通知支持同时发送给多个收件人
Step 1 : 安装包,通过Nuget安装包
Install-Package EasyNotice.Core
Install-Package EasyNotice.Email
Step 2 : 配置 Startup 启动类
public class Startup
{
//...
public void ConfigureServices(IServiceCollection services)
{
//configuration
services.AddEasyNotice(config =>
{
config.IntervalSeconds = 10;//同一标题的消息,10秒内只能发一条,避免短时间内大量发送重复消息
config.UseEmail(option =>
{
option.Host = "smtp.qq.com";//SMTP地址
option.Port = 465;//SMTP端口
option.FromName = "System";//发送人名字(自定义)
option.FromAddress = "12345@qq.com";//发送邮箱
option.Password = "passaword";//秘钥
option.ToAddress = new List<string>()//收件人集合
{
"12345@qq.com"
};
});
});
}
}
Step 3 : IEmailProvider服务接口使用
[ApiController]
[Route("[controller]/[action]")]
public class NoticeController : ControllerBase
{
private readonly IEmailProvider _mailProvider;
public NoticeController(IEmailProvider provider)
{
_mailProvider = provider;
}
[HttpGet]
public async Task SendMail([FromQuery] string str)
{
await _mailProvider.SendAsync(str, new Exception(str));
}
}
2. 钉钉通知
Step 1 : 安装包,通过Nuget安装包
Install-Package EasyNotice.Core
Install-Package EasyNotice.Dingtalk
Step 2 : 配置 Startup 启动类
public class Startup
{
//...
public void ConfigureServices(IServiceCollection services)
{
//configuration
services.AddEasyNotice(config =>
{
config.IntervalSeconds = 10;//同一标题的消息,10秒内只能发一条,避免短时间内大量发送重复消息
config.UseDingTalk(option =>
{
option.WebHook = "https://oapi.dingtalk.com/robot/send?access_token=xxxxx";//通知地址
option.Secret = "secret";//签名校验
});
});
}
}
Step 3 : IDingtalkProvider服务接口使用
[ApiController]
[Route("[controller]/[action]")]
public class NoticeController : ControllerBase
{
private readonly IDingtalkProvider _dingtalkProvider;
public NoticeController(IDingtalkProvider dingtalkProvider)
{
_dingtalkProvider = dingtalkProvider;
}
[HttpGet]
public async Task SendDingTalk([FromQuery] string str)
{
await _dingtalkProvider.SendAsync(str, new Exception(str));
}
}
3. 飞书通知
Step 1 : 安装包,通过Nuget安装包
Install-Package EasyNotice.Core
Install-Package EasyNotice.Feishu
Step 2 : 配置 Startup 启动类
public class Startup
{
//...
public void ConfigureServices(IServiceCollection services)
{
//configuration
services.AddEasyNotice(config =>
{
config.IntervalSeconds = 10;//同一标题的消息,10秒内只能发一条,避免短时间内大量发送重复消息
config.UseFeishu(option =>
{
option.WebHook = "https://open.feishu.cn/open-apis/bot/v2/hook/xxxxx";//通知地址
option.Secret = "secret";//签名校验
});
});
}
}
Step 3 : IFeishuProvider服务接口使用
[ApiController]
[Route("[controller]/[action]")]
public class NoticeController : ControllerBase
{
private readonly IFeishuProvider _feishuProvider;
public NoticeController(IFeishuProvider feishuProvider)
{
_feishuProvider = feishuProvider;
}
[HttpGet]
public async Task SendFeishu([FromQuery] string str)
{
await _feishuProvider.SendAsync(str, new Exception(str));
}
}
4. 企业微信通知
Step 1 : 安装包,通过Nuget安装包
Install-Package EasyNotice.Core
Install-Package EasyNotice.Weixin
Step 2 : 配置 Startup 启动类
public class Startup
{
//...
public void ConfigureServices(IServiceCollection services)
{
//configuration
services.AddEasyNotice(config =>
{
config.IntervalSeconds = 10;//同一标题的消息,10秒内只能发一条,避免短时间内大量发送重复消息
config.UseWeixin(option =>
{
option.WebHook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxx";//通知地址
});
});
}
}
Step 3 : IWeixinProvider服务接口使用
[ApiController]
[Route("[controller]/[action]")]
public class NoticeController : ControllerBase
{
private readonly IWeixinProvider _weixinProvider;
public NoticeController(IWeixinProvider weixinProvider)
{
_weixinProvider = weixinProvider;
}
[HttpGet]
public async Task SendWexin([FromQuery] string str)
{
await _weixinProvider.SendAsync(str, new Exception(str));
}
}
更多示例
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- EasyNotice.Core (>= 2.1.4)
- MailKit (>= 2.11.1)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 3.1.17)
-
.NETStandard 2.1
- EasyNotice.Core (>= 2.1.4)
- MailKit (>= 2.11.1)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 3.1.17)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.1.4 | 268 | 6/6/2024 |
| 2.1.3 | 176 | 6/6/2024 |
| 2.1.2 | 165 | 6/6/2024 |
| 2.1.1 | 152 | 6/6/2024 |
| 2.1.0 | 166 | 6/6/2024 |
| 2.0.2 | 746 | 8/23/2023 |
| 2.0.1 | 719 | 5/19/2023 |
| 2.0.0 | 732 | 5/6/2023 |
| 1.5.1 | 760 | 4/7/2023 |
| 1.5.0 | 709 | 4/6/2023 |
| 1.4.0 | 743 | 4/5/2023 |
| 1.3.0 | 750 | 4/5/2023 |
| 1.2.0 | 798 | 4/4/2023 |
| 1.1.1 | 744 | 4/3/2023 |
| 1.1.0 | 687 | 4/3/2023 |
| 1.0.6 | 863 | 11/19/2022 |
| 1.0.5 | 837 | 11/19/2022 |
| 1.0.2 | 886 | 11/19/2022 |
| 1.0.1 | 857 | 11/19/2022 |