Getting Started
Quick Start
Parse your first email in under two minutes.
TypeScript / Node.js
Section titled “TypeScript / Node.js”Call preprocess() with a raw email string, then pass the result to toLLMContext() to get clean Markdown output.
import { preprocess, toLLMContext } from "langmail"import { readFileSync } from "fs"
// load a raw .eml fileconst raw = readFileSync("email.eml", "utf8")
// parse and cleanconst parsed = await preprocess(raw)
// serialize to LLM-ready Markdownconst context = toLLMContext(parsed)
console.log(context)Example output
Section titled “Example output”Given a typical reply-chain email, the output looks like this:
From: Alice <alice@example.com>Subject: Q4 budget reviewDate: 2024-11-12
Hi,
Following up on the Q4 numbers. Can you sendthe updated forecast by Friday?
— [quoted reply removed] —— [signature removed] —Python
Section titled “Python”from langmail import preprocess, to_llm_context
with open("email.eml") as f: raw = f.read()
parsed = preprocess(raw)context = to_llm_context(parsed)
print(context)use langmail_core::{ preprocess, to_llm_context };
let raw = std::fs::read_to_string("email.eml")?;let parsed = preprocess(&raw)?;let context = to_llm_context(&parsed);
println!("{}", context);