Verify.MailMessage
April 9, 2026 ยท View on GitHub
Extends Verify to allow verification of MailMessage and related types.
See Milestones for release notes.
Sponsors
Entity Framework Extensions
Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.
Developed using JetBrains IDEs
NuGet
Usage
[ModuleInitializer]
public static void Initialize() =>
VerifyMailMessage.Initialize();
ContentDisposition
[Fact]
public Task ContentDisposition()
{
var content = new ContentDisposition("attachment; filename=\"filename.jpg\"");
return Verify(content);
}
Results in:
{
DispositionType: attachment,
FileName: filename.jpg
}
ContentType
[Fact]
public Task ContentType()
{
var content = new ContentType("text/html; charset=utf-8")
{
Name = "name.txt"
};
return Verify(content);
}
Results in:
{
MediaType: text/html,
Name: name.txt,
CharSet: utf-8
}
Attachment
[Fact]
public Task Attachment()
{
var attachment = new Attachment(
new MemoryStream("file content"u8.ToArray()),
new ContentType("text/html; charset=utf-8"))
{
Name = "name.txt"
};
return Verify(attachment);
}
Results in:
{
Name: name.txt,
ContentType: {
MediaType: text/html,
Name: name.txt,
CharSet: utf-8
},
ContentId: Guid_1,
ContentDisposition: {
DispositionType: attachment
}
}
MailMessage
[Fact]
public Task MailMessage()
{
var mail = new MailMessage(
from: "from@mail.com",
to: "to@mail.com",
subject: "The subject",
body: "The body");
return Verify(mail);
}
Results in:
{
From: from@mail.com,
To: to@mail.com,
Subject: The subject,
IsBodyHtml: false,
Body: The body
}
Icon
Mail from The Noun Project.

