Skip to content

Commit feb9bbe

Browse files
committed
.
1 parent 96344d8 commit feb9bbe

19 files changed

Lines changed: 2415 additions & 12 deletions

.gitignore

Lines changed: 486 additions & 1 deletion
Large diffs are not rendered by default.

SMTP2Graph/Program.cs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
1-
// See https://aka.ms/new-console-template for more information
2-
Console.WriteLine("Hello, World!");
1+
using Microsoft.Graph;
2+
using Azure.Identity;
3+
using Microsoft.Graph.Models;
4+
5+
var scopes = new[] { "https://graph.microsoft.com/.default" };
6+
7+
var options = new ClientSecretCredentialOptions
8+
{
9+
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
10+
};
11+
12+
var clientSecretCredential = new ClientSecretCredential(
13+
Environment.GetEnvironmentVariable("TENANT_ID"),
14+
Environment.GetEnvironmentVariable("CLIENT_ID"),
15+
Environment.GetEnvironmentVariable("CLIENT_SECRET"),
16+
options
17+
);
18+
19+
20+
var graphClient = new GraphServiceClient(clientSecretCredential, scopes);
21+
22+
await graphClient.Users["support@belowaverage.org"].SendMail.PostAsync(new()
23+
{
24+
Message = new()
25+
{
26+
From = new() { EmailAddress = new() { Address = "support@belowaverage.org" } },
27+
ToRecipients = [new() { EmailAddress = new() { Address = "dylan@belowaverage.org" } }],
28+
Subject = "Hi",
29+
Body = new() { ContentType = BodyType.Html, Content = "Hi" }
30+
},
31+
SaveToSentItems = false
32+
});

SMTP2Graph/SMTP2Graph.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
<TargetFramework>net9.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
<UserSecretsId>d63d6915-df69-48cf-8d6c-88fd2de116f1</UserSecretsId>
89
</PropertyGroup>
910

11+
<ItemGroup>
12+
<PackageReference Include="Azure.Identity" Version="1.17.1" />
13+
<PackageReference Include="Microsoft.Graph" Version="5.98.0" />
14+
</ItemGroup>
15+
1016
</Project>

0 commit comments

Comments
 (0)