Skip to content
Bitzsoft.Integrationsbitzsoft.integrations

Reference

腾讯企业邮箱

腾讯企业邮箱包的 TencentMailOptions 配置字段、企业微信 access_token 鉴权与使用示例。

Last updated

包信息

属性
NuGet 包Bitzsoft.Integrations.EnterpriseMail.Tencent
Provider IDtencent
鉴权企业微信 access_token(CorpId + CorpSecret)
生命周期Transient

配置字段(TencentMailOptions)

字段类型必填默认值说明
CorpIdstring企业微信 CorpId
CorpSecretstring应用的 CorpSecret(需包含邮件权限)
BaseUrlstringhttps://qyapi.weixin.qq.com企业微信 API 基地址
HttpClientNamestringTencentMail命名 HttpClient 名称

配置示例

{
"EnterpriseMail": {
"Tencent": {
"CorpId": "ww1234567890abcdef",
"CorpSecret": "your-mail-corp-secret"
}
}
}

DI 注册

// ① 配置节绑定
builder.Services.AddBitzsoftTencentMail(builder.Configuration.GetSection("EnterpriseMail:Tencent"));
// ② 委托配置
builder.Services.AddBitzsoftTencentMail(options =>
{
options.CorpId = "ww1234567890abcdef";
options.CorpSecret = "your-mail-corp-secret";
});

使用示例

public class TencentMailService(IEnterpriseMailProvider mail)
{
public async Task DeleteAsync(string messageId)
{
await mail.DeleteMessageAsync(messageId);
}
public async Task<MailFolder> CreateFolderAsync(string name)
{
return await mail.CreateFolderAsync(name);
}
}

已知限制

  • CorpSecret 必须包含邮件权限范围,与企业微信通讯录/消息的 Secret 相互独立。
  • 腾讯企业邮箱与企业微信共用 CorpId,但邮件 API 的 Secret 需在企业微信管理后台单独获取。

相关

100%

滚轮或按钮缩放 · 放大后拖动画面 · 双击切换 100% / 200%