Sender for FluentEmail that uses Microsoft Graph API.
Call one of the AddGraphSender extension methods.
var graphSenderOptions = this.Configuration
.GetSection("GraphSenderOptions")
.Get<GraphSenderOptions>();
services.AddFluentEmail("[email protected]")
.AddRazorRenderer()
.AddGraphSender(graphSenderOptions);Example config in appsettings.json
{
"GraphSenderOptions": {
"TenantId": "your tenant id",
"ClientId": "your app id",
"Secret": "your secret here"
}
}The original version only used the user: sendMail Graph API endpoint. This could not handle attachments over 3MB.
Starting with v2, if you have included any attachments, the implementation will switch to the following:
- A draft message is created
- Attachments are added using attachment: createUploadSession
- The mail is sent using message: send.
Mail.ReadWrite permission is required when adding attachments.
Microsoft Docs on using the Graph API to send large attachments
Send method does not have a SaveSentItems argument like
the SendMail method
that was previously used. The SaveSentItems option has been removed and there is no way to disable this anymore. (
See Link 1
, Link 2,
and Link 3).
Uploading attachments to a draft message was contributed by @huntmj01.
The Mail.Send permission must be granted.
Adding attachments? Then the Mail.ReadWrite permissions is also required.
Create new release with creation of new tag on main branch.
Start publish manually, for the new tag. This will push the package to github and nuget.org
Code originally written by Matt Goldman and merged into FluentEmail repo. But it was not published to NuGet until January 2021. Because we needed this implementation we created a separate repo, modified the code a bit and published it to NuGet.