Skip to content

IFeishuTenantV1MailLabel - 租户邮箱标签API ​

功能描述 ​

飞书邮箱标签API接口实现了修改、查询、删除等邮件标签功能。支持租户管理员通过租户访问令牌管理企业内所有用户的邮箱标签。

参考文档 ​

函数列表 ​

函数名称功能描述认证方式HTTP 方法接口文档
UpdateUserMailboxLabelAsync更新标签TenantAccessTokenPATCHUpdateUserMailboxLabelAsync
GetUserMailboxLabelListAsync列出标签TenantAccessTokenGETGetUserMailboxLabelListAsync
GetUserMailboxLabelAsync获取标签信息TenantAccessTokenGETGetUserMailboxLabelAsync
DeleteUserMailboxLabelAsync删除标签TenantAccessTokenDELETEDeleteUserMailboxLabelAsync
CreateUserMailboxLabelAsync创建标签TenantAccessTokenPOSTCreateUserMailboxLabelAsync

函数详细内容 ​

UpdateUserMailboxLabelAsync ​

更新标签

函数签名

csharp
Task<FeishuApiResult<UserMailboxLabelOopsResult>?> UpdateUserMailboxLabelAsync(
    [Path] string user_mailbox_id,
    [Path] string label_id,
    [Body] UpdateUserMailboxLabelRequest updateUserMailboxLabelRequest,
    CancellationToken cancellationToken = default);

认证 TenantAccessToken(租户访问令牌)

参数

参数名类型必填描述示例
user_mailbox_idstring✅用户邮箱地址,作为用户邮箱身份标识。使用 user_access_token 调用时,可使用占位符 me 表示当前授权用户的主邮箱。user@example.com
label_idstring✅标签ID,创建标签成功后返回的标签ID,或可通过列出标签、获取邮件详情等接口获得7620003644728938013
updateUserMailboxLabelRequestUpdateUserMailboxLabelRequest✅更新用户邮箱标签请求对象-
cancellationTokenCancellationToken⚪取消操作令牌对象default

响应

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "label": {
      "id": "7620003644728938013",
      "name": "更新后的标签名称",
      "background_color": "blue"
    }
  }
}

说明

  • 更新用户指定标签的名字、颜色等信息
  • 使用 tenant_access_token 时,需要申请邮箱标签资源的数据权限

代码示例

csharp
var labelApi = feishuApp.GetApi<IFeishuTenantV1MailLabel>();
var request = new UpdateUserMailboxLabelRequest
{
    Label = new MailLabel { Name = "更新后的标签名称", BackgroundColor = "blue" }
};
var result = await labelApi.UpdateUserMailboxLabelAsync("user@example.com", "7620003644728938013", request);
Console.WriteLine($"标签更新成功: {result?.Data?.Label?.Name}");

GetUserMailboxLabelListAsync ​

列出标签

函数签名

csharp
Task<FeishuApiResult<GetUserMailboxLabelListResult>?> GetUserMailboxLabelListAsync(
    [Path] string user_mailbox_id,
    CancellationToken cancellationToken = default);

认证 TenantAccessToken(租户访问令牌)

参数

参数名类型必填描述示例
user_mailbox_idstring✅用户邮箱地址,作为用户邮箱身份标识。使用 user_access_token 调用时,可使用占位符 me 表示当前授权用户的主邮箱。user@example.com
cancellationTokenCancellationToken⚪取消操作令牌对象default

响应

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "items": [
      {
        "id": "7620003644728938013",
        "name": "重要邮件",
        "background_color": "red",
        "messages_unread": 5
      }
    ]
  }
}

说明

  • 列出邮件标签,包括ID、名称、颜色、未读信息等内容
  • 使用 tenant_access_token 时,需要申请邮箱标签资源的数据权限

代码示例

csharp
var labelApi = feishuApp.GetApi<IFeishuTenantV1MailLabel>();
var result = await labelApi.GetUserMailboxLabelListAsync("user@example.com");
if (result?.Data?.Items != null)
{
    foreach (var label in result.Data.Items)
    {
        Console.WriteLine($"标签: {label.Name}, 未读: {label.MessagesUnread}");
    }
}

GetUserMailboxLabelAsync ​

获取标签信息

函数签名

csharp
Task<FeishuApiResult<GetUserMailboxLabelResult>?> GetUserMailboxLabelAsync(
    [Path] string user_mailbox_id,
    [Path] string label_id,
    CancellationToken cancellationToken = default);

认证 TenantAccessToken(租户访问令牌)

参数

参数名类型必填描述示例
user_mailbox_idstring✅用户邮箱地址,作为用户邮箱身份标识。使用 user_access_token 调用时,可使用占位符 me 表示当前授权用户的主邮箱。user@example.com
label_idstring✅标签ID,创建标签成功后返回的标签ID,或可通过列出标签、获取邮件详情等接口获得7620003644728938013
cancellationTokenCancellationToken⚪取消操作令牌对象default

响应

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "label": {
      "id": "7620003644728938013",
      "name": "重要邮件",
      "background_color": "red",
      "messages_unread": 5
    }
  }
}

说明

  • 根据指定ID,获取邮件标签信息,包括名称、未读数据、颜色等信息
  • 使用 tenant_access_token 时,需要申请邮箱标签资源的数据权限

代码示例

csharp
var labelApi = feishuApp.GetApi<IFeishuTenantV1MailLabel>();
var result = await labelApi.GetUserMailboxLabelAsync("user@example.com", "7620003644728938013");
Console.WriteLine($"标签名称: {result?.Data?.Label?.Name}, 颜色: {result?.Data?.Label?.BackgroundColor}");

DeleteUserMailboxLabelAsync ​

删除标签

函数签名

csharp
Task<FeishuNullDataApiResult?> DeleteUserMailboxLabelAsync(
    [Path] string user_mailbox_id,
    [Path] string label_id,
    CancellationToken cancellationToken = default);

认证 TenantAccessToken(租户访问令牌)

参数

参数名类型必填描述示例
user_mailbox_idstring✅用户邮箱地址,作为用户邮箱身份标识。使用 user_access_token 调用时,可使用占位符 me 表示当前授权用户的主邮箱。user@example.com
label_idstring✅标签ID,创建标签成功后返回的标签ID,或可通过列出标签、获取邮件详情等接口获得7620003644728938013
cancellationTokenCancellationToken⚪取消操作令牌对象default

响应

json
{
  "code": 0,
  "msg": "success",
  "data": null
}

说明

  • 删除用户指定的标签,注意,删除的标签无法恢复
  • 使用 tenant_access_token 时,需要申请邮箱标签资源的数据权限

代码示例

csharp
var labelApi = feishuApp.GetApi<IFeishuTenantV1MailLabel>();
var result = await labelApi.DeleteUserMailboxLabelAsync("user@example.com", "7620003644728938013");
Console.WriteLine($"标签删除结果: {result.Code == 0}");

CreateUserMailboxLabelAsync ​

创建标签

函数签名

csharp
Task<FeishuApiResult<UserMailboxLabelOopsResult>?> CreateUserMailboxLabelAsync(
    [Path] string user_mailbox_id,
    [Body] CreateUserMailboxLabelRequest createUserMailboxLabelRequest,
    CancellationToken cancellationToken = default);

认证 TenantAccessToken(租户访问令牌)

参数

参数名类型必填描述示例
user_mailbox_idstring✅用户邮箱地址,作为用户邮箱身份标识。使用 user_access_token 调用时,可使用占位符 me 表示当前授权用户的主邮箱。user@example.com
createUserMailboxLabelRequestCreateUserMailboxLabelRequest✅创建用户邮箱标签请求对象-
cancellationTokenCancellationToken⚪取消操作令牌对象default

响应

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "label": {
      "id": "7620003644728938013",
      "name": "新标签",
      "background_color": "green"
    }
  }
}

说明

  • 根据用户指定的名称、颜色等信息,创建邮件标签
  • 使用 tenant_access_token 时,需要申请邮箱标签资源的数据权限

代码示例

csharp
var labelApi = feishuApp.GetApi<IFeishuTenantV1MailLabel>();
var request = new CreateUserMailboxLabelRequest
{
    Label = new MailLabel { Name = "新标签", BackgroundColor = "green" }
};
var result = await labelApi.CreateUserMailboxLabelAsync("user@example.com", request);
Console.WriteLine($"标签创建成功: {result?.Data?.Label?.Id}");