diff --git a/FluentEmail.Graph.sln b/FluentEmail.Graph.sln index 3fc47b3..41414bf 100644 --- a/FluentEmail.Graph.sln +++ b/FluentEmail.Graph.sln @@ -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 @@ -51,6 +55,18 @@ 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 @@ -58,6 +74,7 @@ Global 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} diff --git a/sample/SendMailSample/Program.cs b/sample/SendMailSample/Program.cs new file mode 100644 index 0000000..43ece9e --- /dev/null +++ b/sample/SendMailSample/Program.cs @@ -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(); + var provider = services.BuildServiceProvider(); + + //get mail service + var eamil = provider.GetRequiredService(); + var sender = provider.GetRequiredService(); + 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(); + + return graphSenderOptions; + } + + private static string GetTestMailBody() + { + return @" + + + + + + +Test mail ok
+Bold text + +"; + } + } +} diff --git a/sample/SendMailSample/SendMailSample.csproj b/sample/SendMailSample/SendMailSample.csproj new file mode 100644 index 0000000..6b35d9e --- /dev/null +++ b/sample/SendMailSample/SendMailSample.csproj @@ -0,0 +1,25 @@ + + + + Exe + netcoreapp3.1 + + + + + + + + + + + + + + + + Always + + + + diff --git a/sample/SendMailSample/appsettings.json b/sample/SendMailSample/appsettings.json new file mode 100644 index 0000000..30d5108 --- /dev/null +++ b/sample/SendMailSample/appsettings.json @@ -0,0 +1,8 @@ +{ + "GraphSenderOptions": { + "ClientId": "52b3b282-1dd8-41fe-8885-7cdb31b56bea", + "TenantId": "75e18ae3-0902-4ac7-b716-7360d1282372", + "Secret": "5D-7Q~rfRHqdL2m9PU_xDDgBQVtlK5i2Cznk0", + "SaveSentItems": true + } +} \ No newline at end of file diff --git a/src/FluentEmail.Graph/FluentEmail.Graph.csproj b/src/FluentEmail.Graph/FluentEmail.Graph.csproj index 548d49e..6cfadef 100644 --- a/src/FluentEmail.Graph/FluentEmail.Graph.csproj +++ b/src/FluentEmail.Graph/FluentEmail.Graph.csproj @@ -41,7 +41,9 @@ all - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all