eml-to-kb

A bulk .eml email conversion tool that converts .eml files in a specified folder into documents, outputting PDF by default (preserving original email layout, embedding inline images as base64 to ensure display); when explicitly requested, supports --format md to output Markdown. Regular attachments (V1) are saved to local disk. Supports configurable masking (--mask: all/none/id/phone/bank/name, default all, covering phone numbers, ID numbers, bank cards (Luhn check), and customer names—with customer names requiring manual review). PDFs are generated using the system browser headless print mode without extra pip packages. Processed emails are marked with .done to avoid reprocessing. Supports specifying output directory and can upload to IMA knowledge base on request (checks connector connection before upload).

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "eml-to-kb" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-46debd5cc280131cdf0f6384afb606855a501b6855e895cf36f7cec3060ed7d7. Verify the upstream source and version against https://skillhub.cn/skills/user_1aeb512d/eml-to-md before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

A bulk .eml email conversion tool that converts .eml files in a specified folder into documents, outputting PDF by default (preserving original email layout, embedding inline images as base64 to ensure display); when explicitly requested, supports --format md to output Markdown. Regular attachments (V1) are saved to local disk. Supports configurable masking (--mask: all/none/id/phone/bank/name, default all, covering phone numbers, ID numbers, bank cards (Luhn check), and customer names—with customer names requiring manual review). PDFs are generated using the system browser headless print mode without extra pip packages. Processed emails are marked with .done to avoid reprocessing. Supports specifying output directory and can upload to IMA knowledge base on request (checks connector connection before upload).

0 Downloads

Introduction source: third_party · user_1aeb512d · 1.0.1 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Inputs and outputs
Translation pending; see source documentation.
Limits and differences
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: eml-to-kb
description: "把指定文件夹中的 .eml 邮件批量转换成文档,默认输出 PDF(按邮件原格式排版、内联图 base64 直接内嵌绝不会打不开);用户明确要求 md 时加 --format md 转 Markdown。普通附件(V1: 存盘)。脱敏范围可配置(--mask: all/none/id/phone/bank/name 组合,默认 all 含手机/身份证/银行卡号 Luhn 校验 + 客户名人工复查)。PDF 用系统浏览器(Edge/Chrome)无头打印,无需 pip 装包。原邮件处理完标记 .done 防重复。支持用户指定输出目录,并可在用户要求时上传到 ima 知识库(先判断连接器是否连接)。"
read_when:
  - 用户要把邮件/多个 eml 转成文档或知识库
  - 邮件入库、foxmail 导出、qq 邮件转 markdown/pdf、本地邮件知识库、eml 转 md、把邮件存成文件

eml-to-kb

把文件夹里的 .eml 邮件批量转成本地文档(默认 PDF,要 md 时 --format md)。链路只认 eml 标准格式,与来源无关——Foxmail 导出、QQ 邮箱、163、Gmail、Outlook 等只要能导出 .eml 都支持。

工作流程

1. 确认输入与输出

  • 输入:用户指定的文件夹(里面是 .eml)。用户没说就主动问:"要转换的 eml 在哪个文件夹?"
  • 输出:
    • 若用户明确指定了本地文件夹 → 用他指定的作为输出目录
    • 否则 → 默认 <输入文件夹>/pdf/(md 模式则是 <输入文件夹>/success/)
  • 邮件挑选由用户自己完成(在 Foxmail/邮箱网页里手动选中导出 eml 到输入文件夹),脚本只转换、不挑。

2. 运行转换脚本

用已装好 html2text 的隔离 Python 执行。最稳调用方式(避开 Git Bash 中文 argv / 跨盘路径坑):

cd "<输入文件夹>"          # 先进入输入目录(支持中文目录名)
PY="C:/Users/WangGuansheng/.workbuddy/binaries/python/envs/default/Scripts/python.exe"
"$PY" "C:/Users/WangGuansheng/.workbuddy/skills/eml-to-kb/scripts/eml_to_md.py" --input "."
# 如需调整脱敏范围, 末尾追加 --mask none / --mask id / --mask phone,bank 等(默认 all)
# 默认已转 PDF;如要 md 而非 pdf(默认), 追加 --format md
  • 脚本/Python 绝对路径用显式 C:/ 盘符,勿用 /c/(cwd 在 D: 盘时 MSYS 会把 /c/... 误解析成 D:\c\...)
  • 输入用 "." 相对路径(先 cd 进目录),避开中文目录名经 argv 传给 Python 的编码乱码问题
  • 若需指定输出:--output "<输出文件夹>"(同样优先 cd 进目录后用相对/显式盘符路径)
  • 脱敏范围(按用户意图决定是否追加 --mask):默认 all(手机+身份证+银行卡+客户名全脱)。用户说:
    • "不需要脱敏"/"不要脱敏"/"保留原文"/"别打码" → 追加 --mask none
    • "只脱身份证号"/"只脱身份证" → 追加 --mask id
    • "只脱手机号"/"脱手机号和银行卡" → 追加 --mask phone 或 --mask phone,bank
    • 用户没提脱敏 → 不加(即默认 all)
    • 注意:name(客户名人工复查)属于 all 的一部分;none 时连客户名也不进复查清单。多类别用逗号连,如 phone,id。
  • 输出格式(--format):默认 pdf(按邮件原格式排成 PDF,内联图以 base64 直接内嵌进 PDF——不存在"打不开",排版由脚本 CSS 控制、干净统一;底层调系统浏览器 Edge/Chrome 无头 --print-to-pdf,无需 pip 装包)。
    • 用户明确要求要 md 时:加 --format md。生成 Markdown(内联图用相对链接)。已知短板:① html2text 把富文本 HTML 转 md 容易格式乱;② 相对图链能否打开依赖查看器(Obsidian 里通常行,别的预览器/网页常解析不到)。
    • 何时用 md:用户想放进 Obsidian 做全文检索/图谱,或明确说"转 md / 不要 pdf"时。
    • 依赖:PDF 模式需系统装有 Edge 或 Chrome,脚本自动探测;没有则报错提示用 --pdf-engine 指定 exe 路径。 脚本行为:
  • 解析每封 eml → 提取内联图(md: 存盘到 attachments/<年-月>/ 并用相对链接嵌入;pdf: 以 base64 内嵌进 PDF,不写盘)→ 提取普通附件(V1: 存盘)
  • 脱敏:手机号/身份证/银行卡号(Luhn 校验通过)直接打码;客户名正则抓疑似 → 标记 ⚠待审:姓名 并写入 review_list.md,不打码
  • 写出文档(md: frontmatter + 正文;pdf: 邮件头 + 正文 + 底部附件清单)到输出文件夹
  • 原 eml 重命名为 .eml.done(幂等,下次不再转换)
  • 跑完打印摘要:处理 N 封 [格式] | 脱敏命中 X 封 | 待审客户名 Y 处 | 见 review_list.md

3. 汇报与人工复查

  • 把摘要告诉用户。
  • 提醒:若 review_list.md 有待审客户名,需人工确认——确认是客户名就加进 config/names.txt(每行一个),下次自动打码为 [NAME];不是就手动删掉文档里的 ⚠待审: 标记。

4. 可选:上传到 ima 知识库(仅当用户明确要求时)

按用户要求走:

  1. 判断 ima 连接器是否已连接:调用 mcp__ima-mcp__get_knowledge_base_list 探活。
    • 报错/工具不可用 → 提醒用户:请在 WorkBuddy 连接器设置里连接「ima 知识库」,连好后再让我上传。
    • 已连接 → 继续下一步。
  2. 检查 ima-mcp 是否提供上传/导入能力:
    • 若有对应上传工具 → 调用把 <输出文件夹>/ 下所有 .md 或 .pdf 上传到指定知识库。
    • 若当前 ima-mcp 仅提供检索能力(无上传工具)→ 如实告知用户:当前 ima 连接器暂只支持检索,不支持直接上传;请通过 ima 网页/客户端手动导入 <输出文件夹> 下的文档(文件已就绪可直接导入),并给出该绝对路径。

目录约定

<输入文件夹>/
├─ xxx.eml            ← 待转换(处理完变 xxx.eml.done)
├─ xxx.eml.done      ← 已处理标记(幂等,不再转换)
└─ pdf/              ← 默认输出(pdf 模式;用户指定则改用指定目录)
   ├─ 邮件主题.pdf     ← 转换结果(内联图已内嵌)
   ├─ attachments/
   │  └─ 2026-07/   ← 仅普通附件(doc/xlsx 等),内联图不落盘
   └─ review_list.md  ← 每批待审客户名清单
# md 模式输出示例(--format md):
<输入文件夹>/success/
   ├─ 邮件主题.md     ← 转换结果(带 frontmatter)
   ├─ attachments/
   │  └─ 2026-07/   ← 内联图 + 普通附件
   └─ review_list.md

默认输出子目录:pdf 模式 → <输入>/pdf/,md 模式 → <输入>/success/;用 --output 可覆盖。

脱敏规则

脱敏范围由 --mask 控制,默认 all。可选:none(全不脱)/ id / phone / bank / name,逗号可组合(如 phone,id)。name 指客户名人工复查这一项。

  • 自动打码:手机号 138****5678、身份证 110101*********7891X、银行卡号(13~19 位且过 Luhn 校验)[CARD]
  • 客户名(人工复查):正则抓"尊敬的X先生"等上下文的疑似姓名 → 标记 ⚠待审:姓名 进 review_list.md,不打码
  • 已确认客户名:维护在 config/names.txt,下次自动打码为 [NAME]

注意事项

  • 内联图片:md 模式正文用相对链接嵌入(attachments/<年-月>/xxx.png),能否打开依赖查看器;pdf 模式(默认)直接 base64 内嵌进 PDF,永远打得开。
  • 编码容错:正文按邮件声明 charset 解码(国内邮件常见 gb2312/gbk),兜底 gb18030/gbk/utf-8/latin-1,避免乱码(已修:原硬编码 utf-8 硬解 gb 编码邮件会乱码)。
  • 依赖:html2text 已装入隔离 venv;PDF 模式依赖系统浏览器(Edge/Chrome),无需额外 pip 安装。
  • pdf 模式产出的是独立、可打印、图片内嵌的存档文件;md 模式输出文件夹可直接作为 Obsidian vault 打开,获得全文检索 + 图谱。
  • 路径坑(必看):Git Bash / MSYS 下 —— ① 跨盘时 /c/... 会被误解析为 D:\c\...,脚本/Python 路径务必用显式 C:/...;② 中文目录名直接经 argv 传给 Python 会乱码导致 listdir 为空,务必先 cd 进目录再用 --input ".";③ 恢复 .done 标记的正确写法是 ${f%.done}(只去 .done 保留 .eml),勿写 ${f%.eml.done}(会把 .eml 也去掉变无后缀);④ 含点号文件名(如 ...V0.8)不能用 case "*.*" 判后缀,会误跳过。

Current listing version

1.0.1

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 解决 .eml 邮件批量转 PDF/Markdown 的实际痛点,支持脱敏、附件处理、知识库上传等完整链路
  • 适用于邮件归档、Foxmail/QQ 邮箱导出、本地知识库构建等高频场景
Trigger Precision90/100

Highlights

  • read_when 覆盖典型场景(邮件转文档、eml 转 pdf/md、邮件入库等),触发词精准无歧义
Structure and Standards90/100

Areas to improve

  • description 内容重复 Reported severity: Minor

    顶层 frontmatter 和 skill_body 内部均包含 description,内容一致但存在冗余

    Recommendation: 建议保留一处即可,避免重复维护

Highlights

  • 结构完整:含工作流程、目录约定、脱敏规则、注意事项等
  • 步骤清晰,有端到端调用示例,frontmatter 完整
Execution Reliability90/100

Highlights

  • 脚本路径显式指定 C:/ 盘符,规避 Git Bash 跨盘解析和中文路径乱码问题
  • 异常处理完善:编码容错、浏览器依赖检测、IMA 连接器状态判断、幂等设计(.done 标记)
Evidence Verifiability (mean of the first four)89/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.