/FluentEmail.Graph

Sender for FluentEmail that uses Microsoft Graph API

Primary LanguageC#MIT LicenseMIT

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