Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions FluentEmail.Graph.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{A4341B5B-E943-490B-94AE-D4637A7AF37C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SendMailSample", "sample\SendMailSample\SendMailSample.csproj", "{5C9C773B-43AF-475C-A56A-96CDA259D4D8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -51,13 +55,26 @@ Global
{B01998E7-3FE2-4A66-968A-0B7725309129}.Release|x64.Build.0 = Release|Any CPU
{B01998E7-3FE2-4A66-968A-0B7725309129}.Release|x86.ActiveCfg = Release|Any CPU
{B01998E7-3FE2-4A66-968A-0B7725309129}.Release|x86.Build.0 = Release|Any CPU
{5C9C773B-43AF-475C-A56A-96CDA259D4D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C9C773B-43AF-475C-A56A-96CDA259D4D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C9C773B-43AF-475C-A56A-96CDA259D4D8}.Debug|x64.ActiveCfg = Debug|Any CPU
{5C9C773B-43AF-475C-A56A-96CDA259D4D8}.Debug|x64.Build.0 = Debug|Any CPU
{5C9C773B-43AF-475C-A56A-96CDA259D4D8}.Debug|x86.ActiveCfg = Debug|Any CPU
{5C9C773B-43AF-475C-A56A-96CDA259D4D8}.Debug|x86.Build.0 = Debug|Any CPU
{5C9C773B-43AF-475C-A56A-96CDA259D4D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C9C773B-43AF-475C-A56A-96CDA259D4D8}.Release|Any CPU.Build.0 = Release|Any CPU
{5C9C773B-43AF-475C-A56A-96CDA259D4D8}.Release|x64.ActiveCfg = Release|Any CPU
{5C9C773B-43AF-475C-A56A-96CDA259D4D8}.Release|x64.Build.0 = Release|Any CPU
{5C9C773B-43AF-475C-A56A-96CDA259D4D8}.Release|x86.ActiveCfg = Release|Any CPU
{5C9C773B-43AF-475C-A56A-96CDA259D4D8}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{110F6221-F88C-44D8-B9E3-B3D1B9691DFD} = {D1C8192B-F35B-4433-9E5F-05F9E92DA58F}
{B01998E7-3FE2-4A66-968A-0B7725309129} = {779D4366-494E-4582-ACDA-38D55AEC2EE5}
{5C9C773B-43AF-475C-A56A-96CDA259D4D8} = {A4341B5B-E943-490B-94AE-D4637A7AF37C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F11BF11A-54C0-49CA-B567-850A4C6AC40A}
Expand Down
63 changes: 63 additions & 0 deletions sample/SendMailSample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using FluentEmail.Core;
using FluentEmail.Core.Interfaces;
using FluentEmail.Graph;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace SendMailSample
{
class Program
{
static void Main(string[] args)
{
var services = new ServiceCollection();
services.AddFluentEmail("user@user.com").AddGraphSender(Initial());
services.AddScoped<IFluentEmail, Email>();
var provider = services.BuildServiceProvider();

//get mail service
var eamil = provider.GetRequiredService<IFluentEmail>();
var sender = provider.GetRequiredService<ISender>();
eamil.Sender = sender;


eamil.SetFrom("user@user.com", "testGuy")
.To("user@hotmail.com")
.Subject("Test contact Email ")
.Body(GetTestMailBody());
eamil.Data.IsHtml = true;
var response = eamil.Send();
Console.ReadKey();

}

private static GraphSenderOptions Initial()
{
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)

.Build();
var graphSenderOptions = config
.GetSection("GraphSenderOptions")
.Get<GraphSenderOptions>();

return graphSenderOptions;
}

private static string GetTestMailBody()
{
return @"<!DOCTYPE html>
<html>
<head>
<meta charset=""utf-8"" />
<title></title>
</head>
<body>
Test mail ok<br/>
<b>Bold text</b>
</body>
</html>";
}
}
}
25 changes: 25 additions & 0 deletions sample/SendMailSample/SendMailSample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.23" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.23" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.23" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.23" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\FluentEmail.Graph\FluentEmail.Graph.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions sample/SendMailSample/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"GraphSenderOptions": {
"ClientId": "52b3b282-1dd8-41fe-8885-7cdb31b56bea",
"TenantId": "75e18ae3-0902-4ac7-b716-7360d1282372",
"Secret": "5D-7Q~rfRHqdL2m9PU_xDDgBQVtlK5i2Cznk0",
"SaveSentItems": true
}
}
4 changes: 3 additions & 1 deletion src/FluentEmail.Graph/FluentEmail.Graph.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Graph" Version="4.24.0" />
<PackageReference Include="Microsoft.Graph" Version="4.16.0" />
<PackageReference Include="Microsoft.Graph.Auth" Version="1.0.0-preview.7" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.43.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down