FlexiMail is a test-driven email client for .NET 8 and C# 12 that now supports both Exchange (EWS) and Microsoft Graph through the new FlexiGraphService.
- Exchange and Microsoft Graph mail sending with sent-items copy
FlexiGraphServicefor Graph-based delivery- Asynchronous APIs
- Test-first design with unit and integration coverage
dotnet add package FlexiMail
# or
Install-Package FlexiMailNote: The Exchange constructor of
FlexiMailClientis compiled only fornet8.0andnet9.0. When targetingnet10.0, use the Graph constructor (FlexiMailClient(GraphMailConfigurations)).
using FlexiMail;
using FlexiMail.Models.Configurations;
using FlexiMail.Models.Foundations.Bodies;
using FlexiMail.Models.Foundations.Messages;
var configurations = new ExchangeConfigurations
{
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
TenantId = "your-tenant-id",
Authority = "https://login.microsoftonline.com/{tenantId}",
Scopes = ["https://outlook.office365.com/.default"],
SmtpAddress = "sender@domain.com"
};
var client = new FlexiMailClient(configurations);
await client.SendAndSaveCopyAsync(new FlexiMessage
{
To = ["email@domain.com"],
Subject = "Hello from FlexiMail",
Body = new FlexiBody
{
Content = "This is the message body.",
ContentType = BodyContentType.PlainText
}
});using FlexiMail;
using FlexiMail.Models.Configurations;
using FlexiMail.Models.Foundations.Bodies;
using FlexiMail.Models.Foundations.Messages;
var configurations = new GraphMailConfigurations
{
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
TenantId = "your-tenant-id",
SenderUserIdOrUpn = "sender@domain.com",
Scopes = ["https://graph.microsoft.com/.default"]
};
var client = new FlexiMailClient(configurations);
await client.SendAndSaveCopyAsync(new FlexiMessage
{
To = ["email@domain.com"],
Subject = "Hello from FlexiGraphService",
Body = new FlexiBody
{
Content = "Graph-powered delivery.",
ContentType = BodyContentType.Html
}
});Example appsettings.json snippet:
{
"ExchangeConfigurations": {
"ClientId": "your-client-id",
"ClientSecret": "your-client-secret",
"TenantId": "your-tenant-id",
"SmtpAddress": "sender@domain.com",
"Authority": "https://login.microsoftonline.com/{tenantId}",
"Scopes": ["https://outlook.office365.com/.default"]
},
"GraphMailConfigurations": {
"ClientId": "your-client-id",
"ClientSecret": "your-client-secret",
"TenantId": "your-tenant-id",
"SenderUserIdOrUpn": "sender@domain.com",
"Scopes": ["https://graph.microsoft.com/.default"]
}
}- Brokers: integrations with Exchange and Graph
- Services: core workflows, including
FlexiGraphServicefor Graph - Models: message, body, and configuration contracts
FlexiMailClient chooses the appropriate service based on the provided configuration and always saves a copy to Sent Items.
- Fork the repository
- Create a branch (
git checkout -b users/your-github-id/feature-name) - Commit (
git commit -m "Add feature") - Push (
git push origin users/your-github-id/feature-name) - Open a Pull Request
MIT. See LICENSE.
For questions: contact@mahdhi.com
