Bitzsoft.Integrations.EnterpriseMail.Microsoft365
1.0.0-alpha.9
This is a prerelease version of Bitzsoft.Integrations.EnterpriseMail.Microsoft365.
dotnet add package Bitzsoft.Integrations.EnterpriseMail.Microsoft365 --version 1.0.0-alpha.9
NuGet\Install-Package Bitzsoft.Integrations.EnterpriseMail.Microsoft365 -Version 1.0.0-alpha.9
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="Bitzsoft.Integrations.EnterpriseMail.Microsoft365" Version="1.0.0-alpha.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitzsoft.Integrations.EnterpriseMail.Microsoft365" Version="1.0.0-alpha.9" />
<PackageReference Include="Bitzsoft.Integrations.EnterpriseMail.Microsoft365" />
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 Bitzsoft.Integrations.EnterpriseMail.Microsoft365 --version 1.0.0-alpha.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Bitzsoft.Integrations.EnterpriseMail.Microsoft365, 1.0.0-alpha.9"
#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 Bitzsoft.Integrations.EnterpriseMail.Microsoft365@1.0.0-alpha.9
#: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=Bitzsoft.Integrations.EnterpriseMail.Microsoft365&version=1.0.0-alpha.9&prerelease
#tool nuget:?package=Bitzsoft.Integrations.EnterpriseMail.Microsoft365&version=1.0.0-alpha.9&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Bitzsoft.Integrations.EnterpriseMail.Microsoft365
Microsoft 365 企业邮箱集成,基于 Microsoft Graph API v1.0 实现 IEnterpriseMailProvider。
功能特性
- Microsoft Graph API v1.0,通过 OAuth 2.0 客户端凭据流认证
- 邮件操作:发送、列表、详情、搜索、删除、移动
- 文件夹管理:列表、创建、删除
- 附件管理:列表、下载
- OData
$top/$skip标准分页
安装
.NET CLI
dotnet add package Bitzsoft.Integrations.EnterpriseMail.Microsoft365
PackageReference
<PackageReference Include="Bitzsoft.Integrations.EnterpriseMail.Microsoft365" Version="1.0.0" />
配置
{
"Microsoft365": {
"TenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"ClientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"ClientSecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"DefaultUserEmail": "user@company.com"
}
}
| 配置项 | 说明 | 默认值 |
|---|---|---|
TenantId |
Azure AD 租户 ID | — |
ClientId |
应用程序(客户端)ID | — |
ClientSecret |
客户端密钥 | — |
DefaultUserEmail |
默认用户邮箱地址 | — |
BaseUrl |
Graph API 基地址 | https://graph.microsoft.com/v1.0 |
TokenEndpoint |
OAuth 令牌端点 | https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token |
HttpClientName |
命名 HttpClient | Microsoft365Mail |
注册服务
// 方式一:委托配置
services.AddBitzsoftMicrosoft365Mail(options =>
{
options.TenantId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
options.ClientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
options.ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
options.DefaultUserEmail = "user@company.com";
});
// 方式二:IConfiguration 绑定
services.AddBitzsoftMicrosoft365Mail(configuration, "Microsoft365");
第三方请求日志
内置 Bitzsoft.Integrations.RequestLogging 出站请求记录管道,默认 NullRequestLogStore 不持久化。
// ① 默认:启用记录管道但不持久化(日志丢弃)
services.AddBitzsoftMicrosoft365Mail(options => { /* ... */ });
// ② 持久化:宿主注册 IRequestLogStore 实现后,所有出站请求自动落库
services.AddRequestLogging<MyRequestLogStore>(opts =>
{
opts.MaxBodyLength = 8192;
opts.SensitiveFields.Add("mySecret");
});
services.AddBitzsoftMicrosoft365Mail(options => { /* ... */ });
使用示例
using Bitzsoft.Integrations.EnterpriseMail;
using Bitzsoft.Integrations.EnterpriseMail.Microsoft365;
using Bitzsoft.Integrations.EnterpriseMail.Models;
// 通过 DI 注入 IEnterpriseMailProvider
public class MailService
{
private readonly IEnterpriseMailProvider _mail;
public MailService(IEnterpriseMailProvider mail) => _mail = mail;
public async Task<MailListResult> ListAsync()
{
// OData $top/$skip 分页,无需线性遍历
return await _mail.ListMessagesAsync("inbox", pageIndex: 1, pageSize: 20);
}
public async Task SearchAsync(string keyword)
{
// Graph $search + 客户端过滤
var result = await _mail.SearchAsync(new MailSearchRequest
{
Keyword = keyword,
UnreadOnly = true,
});
}
}
核心类型一览
| 类型 | 说明 |
|---|---|
Microsoft365MailProvider |
Microsoft 365 邮箱服务实现(IEnterpriseMailProvider) |
Microsoft365MailOptions |
Microsoft 365 邮箱配置选项 |
依赖
Bitzsoft.Integrations.EnterpriseMail,企业邮箱抽象层Bitzsoft.Integrations.Compatibility,基础工具库Microsoft.Extensions.Http,命名 HttpClient 工厂
注意事项
- 使用
$top/$skip实现分页,无需线性遍历 - Graph
$search与$filter不能组合使用,复杂搜索通过客户端过滤实现 SendAsync返回 202 Accepted,无法获取发送后的邮件 MessageId- 使用前需在 Azure AD 中注册应用并授予
Mail.ReadWrite、Mail.Send等权限 - Provider 名称:
Microsoft365
相关包
- Bitzsoft.Integrations.EnterpriseMail — 核心抽象层
- Bitzsoft.Integrations.EnterpriseMail.Feishu — 飞书邮箱实现
- Bitzsoft.Integrations.EnterpriseMail.Alibaba — 阿里邮箱实现
- Bitzsoft.Integrations.EnterpriseMail.Tencent — 腾讯企业邮箱实现
- Bitzsoft.Integrations.EnterpriseMail.NetEase — 网易企业邮箱实现
- Bitzsoft.Integrations.EnterpriseMail.All — 全部供应商聚合包
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. 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 is compatible. 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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.0-alpha.9)
- Bitzsoft.Integrations.EnterpriseMail (>= 1.0.0-alpha.9)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.0-alpha.9)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.9)
-
net5.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.0-alpha.9)
- Bitzsoft.Integrations.EnterpriseMail (>= 1.0.0-alpha.9)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.0-alpha.9)
- Microsoft.Extensions.Configuration.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Http (>= 5.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 5.0.0)
-
net8.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.0-alpha.9)
- Bitzsoft.Integrations.EnterpriseMail (>= 1.0.0-alpha.9)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.0-alpha.9)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.9)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Bitzsoft.Integrations.EnterpriseMail.Microsoft365:
| Package | Downloads |
|---|---|
|
Bitzsoft.Integrations.EnterpriseMail.All
企业邮箱服务聚合包 — 包含所有供应商实现 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha.9 | 51 | 7/12/2026 |
| 1.0.0-alpha.8 | 299 | 7/1/2026 |
| 1.0.0-alpha.7 | 71 | 6/16/2026 |
| 1.0.0-alpha.6 | 63 | 6/16/2026 |
| 1.0.0-alpha.5 | 68 | 6/14/2026 |
| 1.0.0-alpha.3 | 70 | 6/7/2026 |