Skip to content

Sender for FluentEmail that uses Microsoft Graph API

License

Notifications You must be signed in to change notification settings

fnuhs/FluentEmail.Graph

 
 

Repository files navigation

FluentEmail.Graph

Sender for FluentEmail that uses Microsoft Graph API.

Nuget

CI CodeQL Publish

Usage

Call one of the AddGraphSender extension methods.

var graphSenderOptions = this.Configuration
    .GetSection("GraphSenderOptions")
    .Get<GraphSenderOptions>();
services.AddFluentEmail("alias@test.com")
    .AddRazorRenderer()
    .AddGraphSender(graphSenderOptions);

Example config in appsettings.json

{
  "GraphSenderOptions": {
    "TenantId": "your tenant id",
    "ClientId": "your app id",
    "Secret": "your secret here"
  }
}

v2

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:

⚠️BREAKING: The Mail.ReadWrite permission is required when adding attachments.

Microsoft Docs on using the Graph API to send large attachments

⚠️REMOVED: Unfortunately, the Microsoft Graph API 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.

Graph API Permissions

The Mail.Send permission must be granted.

Adding attachments? Then the Mail.ReadWrite permissions is also required.

Release

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

Origin

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.

About

Sender for FluentEmail that uses Microsoft Graph API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%