包信息
| 属性 | 值 |
|---|---|
| NuGet 包 | Bitzsoft.Integrations.EnterpriseMail.Tencent |
| Provider ID | tencent |
| 鉴权 | 企业微信 access_token(CorpId + CorpSecret) |
| 生命周期 | Transient |
配置字段(TencentMailOptions)
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
CorpId | string | 是 | — | 企业微信 CorpId |
CorpSecret | string | 是 | — | 应用的 CorpSecret(需包含邮件权限) |
BaseUrl | string | 否 | https://qyapi.weixin.qq.com | 企业微信 API 基地址 |
HttpClientName | string | 否 | TencentMail | 命名 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 需在企业微信管理后台单独获取。
相关
- 企业邮箱域手册:接口设计