initial commit
This commit is contained in:
25
GmailArneMoermanSorter.sln
Normal file
25
GmailArneMoermanSorter.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34221.43
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GmailArneMoermanSorter", "GmailArneMoermanSorter\GmailArneMoermanSorter.csproj", "{3ECD0085-DC1D-429C-87D2-E3FEBC12BBC9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3ECD0085-DC1D-429C-87D2-E3FEBC12BBC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3ECD0085-DC1D-429C-87D2-E3FEBC12BBC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3ECD0085-DC1D-429C-87D2-E3FEBC12BBC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3ECD0085-DC1D-429C-87D2-E3FEBC12BBC9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {35572BF2-9ACB-45E6-8671-ADC9D1D25CC1}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
20
GmailArneMoermanSorter/GmailArneMoermanSorter.csproj
Normal file
20
GmailArneMoermanSorter/GmailArneMoermanSorter.csproj
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Apis.Gmail.v1" Version="1.64.0.3231" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="clientSecret.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
48
GmailArneMoermanSorter/Program.cs
Normal file
48
GmailArneMoermanSorter/Program.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using Google.Apis.Gmail.v1;
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.Util.Store;
|
||||
|
||||
namespace GmailArneMoermanSorter
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Access emails over Gmail Api");
|
||||
try
|
||||
{
|
||||
new Program().Run().Wait();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Run()
|
||||
{
|
||||
UserCredential credential;
|
||||
using (var stream = new FileStream("clientSecret.json", FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
|
||||
GoogleClientSecrets.FromStream(stream).Secrets,
|
||||
new[] {GmailService.Scope.GmailLabels},
|
||||
"user", CancellationToken.None, new FileDataStore("GmailApi.Auth.Store"));
|
||||
}
|
||||
|
||||
var service = new GmailService(new BaseClientService.Initializer()
|
||||
{
|
||||
HttpClientInitializer = credential,
|
||||
ApplicationName = "GmailArneMoermanSorter"
|
||||
});
|
||||
|
||||
var labels = await service.Users.Labels.List("me").ExecuteAsync();
|
||||
foreach (var label in labels.Labels)
|
||||
{
|
||||
Console.WriteLine(label.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
GmailArneMoermanSorter/clientSecret.json
Normal file
3
GmailArneMoermanSorter/clientSecret.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")]
|
||||
@@ -0,0 +1,23 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("GmailArneMoermanSorter")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("GmailArneMoermanSorter")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("GmailArneMoermanSorter")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// <auto-generated/>
|
||||
global using global::System;
|
||||
global using global::System.Collections.Generic;
|
||||
global using global::System.IO;
|
||||
global using global::System.Linq;
|
||||
global using global::System.Net.Http;
|
||||
global using global::System.Threading;
|
||||
global using global::System.Threading.Tasks;
|
||||
Reference in New Issue
Block a user