https://github.com/verifytests/verify.mailmessage
Extends Verify to allow verification of MailMessage and related types.
https://github.com/verifytests/verify.mailmessage
Last synced: 8 months ago
JSON representation
Extends Verify to allow verification of MailMessage and related types.
- Host: GitHub
- URL: https://github.com/verifytests/verify.mailmessage
- Owner: VerifyTests
- License: mit
- Created: 2023-03-31T00:53:12.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-10-07T08:47:00.000Z (9 months ago)
- Last Synced: 2025-10-07T09:37:23.968Z (9 months ago)
- Language: C#
- Homepage:
- Size: 379 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: license.txt
- Code of conduct: code_of_conduct.md
Awesome Lists containing this project
README
#
Verify.MailMessage
[](https://github.com/orgs/VerifyTests/discussions)
[](https://ci.appveyor.com/project/SimonCropp/verify-mailmessage)
[](https://www.nuget.org/packages/Verify.MailMessage/)
Extends [Verify](https://github.com/VerifyTests/Verify) to allow verification of [MailMessage](https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.mailmessage) and related types.
**See [Milestones](../../milestones?state=closed) for release notes.**
## Sponsors
### Entity Framework Extensions
[Entity Framework Extensions](https://entityframework-extensions.net/?utm_source=simoncropp&utm_medium=Verify.MailMessage) is a major sponsor and is proud to contribute to the development this project.
[](https://entityframework-extensions.net/?utm_source=simoncropp&utm_medium=Verify.MailMessage)
## NuGet
* https://nuget.org/packages/Verify.MailMessage
## Usage
```cs
[ModuleInitializer]
public static void Initialize() =>
VerifyMailMessage.Initialize();
```
snippet source | anchor
### ContentDisposition
```cs
[Fact]
public Task ContentDisposition()
{
var content = new ContentDisposition("attachment; filename=\"filename.jpg\"");
return Verify(content);
}
```
snippet source | anchor
Results in:
```txt
{
DispositionType: attachment,
FileName: filename.jpg
}
```
snippet source | anchor
### ContentType
```cs
[Fact]
public Task ContentType()
{
var content = new ContentType("text/html; charset=utf-8")
{
Name = "name.txt"
};
return Verify(content);
}
```
snippet source | anchor
Results in:
```txt
{
MediaType: text/html,
Name: name.txt,
CharSet: utf-8
}
```
snippet source | anchor
### Attachment
```cs
[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);
}
```
snippet source | anchor
Results in:
```txt
{
Name: name.txt,
ContentType: {
MediaType: text/html,
Name: name.txt,
CharSet: utf-8
},
ContentId: Guid_1,
ContentDisposition: {
DispositionType: attachment
}
}
```
snippet source | anchor
### MailMessage
```cs
[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);
}
```
snippet source | anchor
Results in:
```txt
{
From: from@mail.com,
To: to@mail.com,
Subject: The subject,
IsBodyHtml: false,
Body: The body
}
```
snippet source | anchor
## Icon
[Mail](https://thenounproject.com/icon/mail-5633084/) from [The Noun Project](https://thenounproject.com).