---
title: "Decode format=flowed email text in C#"
url: https://recursiveai.org/onemail/cookbook/decode-format-flowed-email/
description: "Join soft-wrapped plain-text email lines in C# using OneMail. Preserve quote depth and handle the RFC 3676 DelSp parameter."
version: "1.0.1"
---

# Decode format=flowed email text in C#

**OneMail** is a free, open-source email library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneMail) · [GitHub](https://github.com/recursive-ai-oss/onemail-csharp) · [Docs](https://recursiveai.org/onemail/docs/) · [Download example (.zip)](https://recursiveai.org/onemail/cookbook/decode-format-flowed-email/decode-format-flowed-email.zip)

Join soft line breaks in a decoded plain-text email body.

```shell
dotnet add package RecursiveAI.OneMail
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneMail.Bodies;
var body = "Meet at \r\nnoon.\r\n";
Console.WriteLine(FormatFlowed.Decode(body));
```

Unzip [the example](https://recursiveai.org/onemail/cookbook/decode-format-flowed-email/decode-format-flowed-email.zip), then `dotnet run`.

Joins the two lines into one sentence.

```text
Meet at noon.
```

## The full program

The full program uses inline strings. Each `\r\n` is a line break. A space before it marks a soft break. The two `>` lines join at quote depth 1. The second doesn’t join the `>>` line because that line is at depth 2. A separate `DelSp=yes` example splits `timezone` across two lines.

```csharp
using RecursiveAI.OneMail.Bodies;

// The space before each soft break is written explicitly.
var body = "Meet at " + "\r\nnoon.\r\n" +
    "> Bring " + "\r\n> the map. " + "\r\n" +
    ">> At the station.\r\n";
var paragraphs = FormatFlowed.Parse(body);
if (!paragraphs.Select(p => p.QuoteDepth).SequenceEqual(new[] { 0, 1, 2 }))
    throw new InvalidDataException("Unexpected quote depths.");

foreach (var paragraph in paragraphs)
    Console.WriteLine($"Depth {paragraph.QuoteDepth}: {paragraph.Text.TrimEnd()}");

var delSp = FormatFlowed.Decode("time " + "\r\nzone.\r\n", delSp: true);
if (delSp.TrimEnd('\r', '\n') != "timezone.")
    throw new InvalidDataException("The DelSp break was not removed.");
Console.WriteLine($"DelSp=yes: {delSp.TrimEnd('\r', '\n')}");
```

`dotnet run` prints:

```text
Depth 0: Meet at noon.
Depth 1: Bring the map.
Depth 2: At the station.
DelSp=yes: timezone.
```

If you don’t know the body was labeled `format=flowed`, leave its line breaks alone; otherwise a trailing space can turn an intentional break into a join.

## Variations

**Decode `DelSp=yes`.** Keep the `using` directive and replace the two lines below it with this example. The trailing space before the line break is removed.

```csharp
var body = "time " + "\r\nzone.\r\n";
Console.WriteLine(FormatFlowed.Decode(body, delSp: true));
```

```text
timezone.
```

**Start from an EML file.** Replace the snippet at the top with this program and use `flowed.eml` from the zip. Here is the sample (the quoted-printable `=20` encodes a trailing space):

```text
From: Ada <ada@example.test>
Date: Thu, 19 Nov 2026 09:00:00 +0000
Subject: Meeting time
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=yes
Content-Transfer-Encoding: quoted-printable

time=20
zone.
```

`TextBody` selects the plain-text body. `IsFormatFlowed` and `FlowedDelSp` read that part’s `Content-Type` parameters. `ReadText()` decodes the transfer encoding and character set first. If the part isn’t marked as flowed, print the text without joining lines.

```csharp
using RecursiveAI.OneMail;
using RecursiveAI.OneMail.Bodies;

using var file = File.OpenRead("flowed.eml");
var part = Mail.Parse(file).TextBody;
if (part is null)
    throw new InvalidDataException("No plain-text body.");

var text = part.ReadText();
Console.WriteLine(part.IsFormatFlowed
    ? FormatFlowed.Decode(text, delSp: part.FlowedDelSp)
    : text);
```

```text
timezone.
```

## Related recipes

[Parse an EML file](https://recursiveai.org/onemail/cookbook/parse-eml/) · [Create an email reply and forward](https://recursiveai.org/onemail/cookbook/create-email-reply-and-forward/)

---

## The short answer

Once you have the decoded `text/plain` body, call `FormatFlowed.Decode` for a display string or `FormatFlowed.Parse` for separate paragraphs and quote depths. Use `delSp: true` only if the part’s `Content-Type` specifies `DelSp=yes`. The `FormatFlowed` calls take body text, not headers or an entire MIME message.

## What is format=flowed in plain-text email?

[`format=flowed` (RFC 3676)](https://www.rfc-editor.org/rfc/rfc3676.html) gives a mail reader a way to tell which line breaks it may move while displaying plain text. In the snippet at the top, the trailing space after `Meet at ` marks a soft break. Joining the next line produces `Meet at noon.` instead of fixing the display to the sender’s wrap width. A fixed line ends its paragraph; a signature separator `-- ` is fixed even though it ends with a space.

Leading `>` characters count as quote markers. In the full example the two lines starting with one `>` form one paragraph, and the two-marker line belongs to a different quote level. A change of depth blocks a join even if the preceding line has a soft break. OneMail also removes the extra leading space used to protect lines that would otherwise look like special syntax. [The flowed-body docs](https://recursiveai.org/onemail/docs/bodies/) describe both rules.

## What does DelSp=yes do in a flowed email body?

It tells the decoder to delete the one trailing space that marks each soft break as it joins the lines. With `DelSp=yes`, `time ` followed by `zone.` becomes `timezone.`. Without it, the space is kept, which is what you want when `Meet at ` is followed by `noon.`. Don’t pick `delSp` by inspecting the English text; read the declared parameter for that part. An absent parameter uses the default behavior, which keeps the space.

## How do I decode the plain-text body of an email in C#?

Separate MIME decoding from flowed decoding. A message can first require its transfer encoding and character set to be decoded before the result is a C# string. Then, if that plain-text part says `format=flowed`, pass the string to the snippet at the top. Trimming lines in between removes the trailing spaces that tell the decoder where to join.

Choose `Decode` if you want one plain-text string with quote markers. Choose `Parse` if you want to keep the quote level as a number, for example to indent quoted paragraphs in a reader. Neither method renders HTML or turns an HTML part into text.
