bsmd.Mail auf IMAP erweitert
6.4.2 ExcelReader ausgeliefert log4net und Sqlite Libs Versionen erhöht
This commit is contained in:
parent
a3083680e6
commit
3a4209fb5c
Binary file not shown.
@ -74,26 +74,14 @@ namespace bsmd.ExcelReadService
|
||||
// BSMDPopClient.PrintCapabilities();
|
||||
// BSMDPopClient.PrintSslConnectionInfo();
|
||||
|
||||
using (BSMDPopClient bsmdPopClient = new BSMDPopClient())
|
||||
using (BSMDImapClient bsmdImapClient = new BSMDImapClient())
|
||||
{
|
||||
if(bsmdPopClient.IsConnected)
|
||||
if(bsmdImapClient.IsConnected)
|
||||
{
|
||||
|
||||
|
||||
// --- BEGIN ------------ TEST
|
||||
|
||||
/*
|
||||
ExcelReader er = new ExcelReader(@"E:\work\bsmd\nsw\Source\bsmd.ExcelReadService\2016_01_08_BMSD - EUNoAD Tool Rev 3.0_mit Testdaten.xls");
|
||||
string amsg;
|
||||
MessageCore aCore;
|
||||
bool aReadResult = Util.ProcessSheet(er, out amsg, out aCore);
|
||||
er.Dispose();
|
||||
*/
|
||||
|
||||
// --- END --------------- TEST
|
||||
|
||||
// check and download next e-Mail, saving attachment
|
||||
while (bsmdPopClient.ReceiveSingleMail(out attachmentLocalPath, out messageId, out mailSender, out mailSubject))
|
||||
while (bsmdImapClient.ReceiveSingleMail(out attachmentLocalPath, out messageId, out mailSender, out mailSubject))
|
||||
{
|
||||
|
||||
bool readResult = false;
|
||||
@ -231,7 +219,7 @@ namespace bsmd.ExcelReadService
|
||||
|
||||
// remove e-Mail
|
||||
_log.InfoFormat("deleting mail with messageId {0}", messageId);
|
||||
_log.InfoFormat("mail delete {0}", bsmdPopClient.DeleteMessageByMessageId(messageId) ? "successful" : "failed");
|
||||
_log.InfoFormat("mail delete {0}", bsmdImapClient.DeleteMessageByMessageId(messageId) ? "successful" : "failed");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,25 +35,22 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="OpenPop, Version=2.0.6.1120, Culture=neutral, PublicKeyToken=6bdb97f144b7efc8, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\OpenPop.NET.2.0.6.1120\lib\net40\OpenPop.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SQLite, Version=1.0.108.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Data.SQLite.Core.1.0.108.0\lib\net45\System.Data.SQLite.dll</HintPath>
|
||||
<Reference Include="System.Data.SQLite, Version=1.0.114.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.114.0\lib\net45\System.Data.SQLite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
@ -132,12 +129,12 @@
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\System.Data.SQLite.Core.1.0.108.0\build\net45\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.108.0\build\net45\System.Data.SQLite.Core.targets')" />
|
||||
<Import Project="..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.114.0\build\net45\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.114.0\build\net45\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.108.0\build\net45\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.108.0\build\net45\System.Data.SQLite.Core.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.114.0\build\net45\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.114.0\build\net45\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="log4net" version="2.0.8" targetFramework="net45" />
|
||||
<package id="OpenPop.NET" version="2.0.6.1120" targetFramework="net45" />
|
||||
<package id="System.Data.SQLite.Core" version="1.0.108.0" targetFramework="net45" />
|
||||
<package id="log4net" version="2.0.12" targetFramework="net45" />
|
||||
<package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.114.0" targetFramework="net45" />
|
||||
<package id="System.Data.SQLite.Core" version="1.0.114.3" targetFramework="net45" />
|
||||
</packages>
|
||||
@ -2,6 +2,6 @@
|
||||
|
||||
[assembly: AssemblyCompany("schick Informatik")]
|
||||
[assembly: AssemblyProduct("BSMD NSW interface")]
|
||||
[assembly: AssemblyInformationalVersion("6.4.1")]
|
||||
[assembly: AssemblyInformationalVersion("6.4.2")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014-2021 schick Informatik")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion("6.4.1.*")]
|
||||
[assembly: AssemblyVersion("6.4.2.*")]
|
||||
|
||||
|
||||
@ -40,20 +40,21 @@
|
||||
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\ENI-2\ENI2\ENI2\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\..\ENI-2\ENI2\ENI2\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
@ -142,6 +143,7 @@
|
||||
<None Include="..\bsmdKey.snk" />
|
||||
<None Include="bsmd.database.licenseheader" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="versions.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="log4net" version="2.0.8" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net45" />
|
||||
<package id="log4net" version="2.0.12" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net45" />
|
||||
</packages>
|
||||
48
nsw/Source/bsmd.database/versions.md
Normal file
48
nsw/Source/bsmd.database/versions.md
Normal file
@ -0,0 +1,48 @@
|
||||
# NSW Versionen der Komponenten
|
||||
___
|
||||
|
||||
"Major" geht immer nach NSW Zählung. Aktuell (2021) haben wir NSW 6.0, also fangen unsere Versionen mit "6" an.
|
||||
|
||||
# Planung
|
||||
|
||||
6.4.2 ExcelReadService
|
||||
NEU: log4net 2.0.8 -> 2.0.12 // Muss bei allen abhängigen Projekten beachtet werden!
|
||||
Newtonsoft.JSON 13.0.1
|
||||
|
||||
# Aktuell installiert bei BSMD
|
||||
|
||||
## 3.8.8
|
||||
|
||||
LockingService (Anmeldungen sperren) vom 23.11.17
|
||||
|
||||
## 5.8.0
|
||||
|
||||
nswservice DBH (Antworten, IIS) vom 2.12.19
|
||||
|
||||
## 6.0.7
|
||||
|
||||
ReportGenerator vom 13.5.20
|
||||
|
||||
## 6.0.8
|
||||
|
||||
POService vom 15.7.20
|
||||
|
||||
## 6.1.0
|
||||
|
||||
nsw.service (Wetris Datenabruf) vom 15.3.21
|
||||
|
||||
## 6.2.0
|
||||
|
||||
ExcelReadService (classic mit Pop3) vom 26.4.21
|
||||
|
||||
## 6.4.0
|
||||
|
||||
SendNSWMessageService vom 1.6.21
|
||||
|
||||
## 6.4.1
|
||||
|
||||
ENI vom 2.6.21, freigegebene Version
|
||||
log4net 2.0.8
|
||||
|
||||
|
||||
|
||||
214
nsw/Source/bsmd.email/BSMDImapClient.cs
Normal file
214
nsw/Source/bsmd.email/BSMDImapClient.cs
Normal file
@ -0,0 +1,214 @@
|
||||
// Description: IMAP Client analog zu POP3 Client
|
||||
// Copyright (c) 2021 Informatikbüro Daniel Schick
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Net.Security;
|
||||
|
||||
using System.IO;
|
||||
using log4net;
|
||||
|
||||
using MimeKit;
|
||||
using MailKit;
|
||||
using MailKit.Security;
|
||||
using MailKit.Net.Imap;
|
||||
|
||||
|
||||
using EmailValidation;
|
||||
|
||||
namespace bsmd.email
|
||||
{
|
||||
public class BSMDImapClient : IDisposable
|
||||
{
|
||||
|
||||
private readonly ImapClient imapClient;
|
||||
private readonly ILog _log = LogManager.GetLogger(typeof(BSMDImapClient));
|
||||
|
||||
#region Creation / Destroy
|
||||
|
||||
public BSMDImapClient()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.imapClient = new ImapClient(new MailKitLogger());
|
||||
// this.imapClient.ServerCertificateValidationCallback = ValidateServerCertificate; // hack? to accept everything
|
||||
bool useSSL = true;
|
||||
this.imapClient.Connect(Properties.Settings.Default.IMAPServer, Properties.Settings.Default.IMAPPort, useSSL);
|
||||
this.imapClient.Authenticate(Properties.Settings.Default.IMAPUser, Properties.Settings.Default.IMAPPassword);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.ErrorFormat("Error connecting to IMAP Server {0}: {1}", Properties.Settings.Default.IMAPServer, ex.Message);
|
||||
_log.DebugFormat("User:{0} Pw:{1}", Properties.Settings.Default.IMAPUser, Properties.Settings.Default.IMAPPassword);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (imapClient.IsConnected)
|
||||
imapClient.Disconnect(true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Hack
|
||||
|
||||
/// <summary>
|
||||
/// Diese Funktion validiert *jedes* Zertifikat und ist eigentlich scheiße. Das geht nur so im abgeschlossenen BSMD Netz!
|
||||
/// </summary>
|
||||
public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public bool IsConnected { get { return this.imapClient.IsConnected; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region public methods
|
||||
|
||||
public bool ReceiveSingleMail(out string attachmentLocalFile, out string messageId, out string sender, out string subject)
|
||||
{
|
||||
attachmentLocalFile = null;
|
||||
messageId = null;
|
||||
sender = null;
|
||||
subject = null;
|
||||
|
||||
if (!imapClient.IsConnected) return false;
|
||||
imapClient.Inbox.Open(FolderAccess.ReadWrite);
|
||||
|
||||
IList<UniqueId> ids = imapClient.Inbox.Search(MailKit.Search.SearchQuery.All);
|
||||
|
||||
if(ids.Count > 0)
|
||||
{
|
||||
MimeMessage mailMessage = imapClient.Inbox.GetMessage(ids[0]);
|
||||
if ((mailMessage.Sender != null) && EmailValidator.Validate(mailMessage.Sender.Address))
|
||||
sender = mailMessage.Sender.Address;
|
||||
if ((sender == null) && (mailMessage.From.Count > 0))
|
||||
{
|
||||
foreach (MailboxAddress ma in mailMessage.From.Mailboxes)
|
||||
{
|
||||
if (EmailValidator.Validate(ma.Address))
|
||||
{
|
||||
sender = ma.Address;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
messageId = mailMessage.MessageId;
|
||||
subject = mailMessage.Subject;
|
||||
|
||||
foreach (MimeEntity attachment in mailMessage.Attachments)
|
||||
{
|
||||
if (attachment is MessagePart rfc822)
|
||||
{
|
||||
string filename = attachment.ContentDisposition?.FileName;
|
||||
if (filename == null)
|
||||
{
|
||||
_log.InfoFormat("attachment {0} has no filename", attachment.ContentId);
|
||||
continue;
|
||||
}
|
||||
_log.InfoFormat("found attachment named {0}, ContentType {1}", filename, attachment.ContentType);
|
||||
|
||||
if (filename.EndsWith(".xls", StringComparison.InvariantCultureIgnoreCase) ||
|
||||
filename.EndsWith(".xlsx", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
attachmentLocalFile = Path.Combine(Properties.Settings.Default.ArchiveFolder, filename);
|
||||
using (var stream = File.Create(attachmentLocalFile))
|
||||
rfc822.Message.WriteTo(stream);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var part = (MimePart)attachment;
|
||||
var filename = part.FileName;
|
||||
if (filename != null)
|
||||
{
|
||||
if (filename.EndsWith(".xls", StringComparison.InvariantCultureIgnoreCase) ||
|
||||
filename.EndsWith(".xlsx", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
attachmentLocalFile = Path.Combine(Properties.Settings.Default.ArchiveFolder, filename);
|
||||
using (var stream = File.Create(attachmentLocalFile))
|
||||
part.Content.DecodeTo(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true; // new mail message
|
||||
}
|
||||
|
||||
_log.Info("no new mail on server");
|
||||
return false; // no new message on server
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// deletes message referenced by messageId
|
||||
/// </summary>
|
||||
/// <returns>true if successful</returns>
|
||||
public bool DeleteMessageByMessageId(string messageId)
|
||||
{
|
||||
if (!IsConnected) return false;
|
||||
|
||||
// find the message
|
||||
IList<UniqueId> deleteList = this.imapClient.Inbox.Search(MailKit.Search.SearchQuery.HeaderContains("Message-Id", messageId));
|
||||
|
||||
if(deleteList.Count == 1)
|
||||
{
|
||||
// mark found message as deleted
|
||||
this.imapClient.Inbox.AddFlags(deleteList[0], MessageFlags.Deleted, true);
|
||||
// clear up inbox
|
||||
this.imapClient.Inbox.Expunge();
|
||||
_log.InfoFormat("Message {0} deleted", messageId);
|
||||
// mark successful
|
||||
return true;
|
||||
}
|
||||
if(deleteList.Count == 0)
|
||||
{
|
||||
_log.WarnFormat("Message {0} to delete not found", messageId);
|
||||
}
|
||||
if(deleteList.Count > 1)
|
||||
{
|
||||
_log.WarnFormat("Very strange: {0} messages found in inbox for id {1}", deleteList.Count, messageId);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region static helper
|
||||
|
||||
|
||||
public static void PrintSslConnectionInfo()
|
||||
{
|
||||
using (var client = new ImapClient())
|
||||
{
|
||||
client.Connect(Properties.Settings.Default.IMAPServer, Properties.Settings.Default.IMAPPort, SecureSocketOptions.Auto);
|
||||
|
||||
Console.WriteLine($"Negotiated the following SSL options with {Properties.Settings.Default.IMAPServer}:");
|
||||
Console.WriteLine($" Protocol Version: {client.SslProtocol}");
|
||||
Console.WriteLine($" Cipher Algorithm: {client.SslCipherAlgorithm}");
|
||||
Console.WriteLine($" Cipher Strength: {client.SslCipherStrength}");
|
||||
Console.WriteLine($" Hash Algorithm: {client.SslHashAlgorithm}");
|
||||
Console.WriteLine($" Hash Strength: {client.SslHashStrength}");
|
||||
Console.WriteLine($" Key-Exchange Algorithm: {client.SslKeyExchangeAlgorithm}");
|
||||
Console.WriteLine($" Key-Exchange Strength: {client.SslKeyExchangeStrength}");
|
||||
|
||||
client.Disconnect(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,4 @@
|
||||
//
|
||||
// Class: Mail
|
||||
// Current CLR: 4.0.30319.34209
|
||||
// System: Microsoft Visual Studio 10.0
|
||||
// Author: dani
|
||||
// Created: 5/28/2015 10:24:12 AM
|
||||
//
|
||||
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
||||
|
||||
// Copyright (c) 2011 rubicon IT GmbH
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
@ -14,10 +14,8 @@ using System.Security.Cryptography.X509Certificates;
|
||||
using System.Net.Security;
|
||||
|
||||
using MimeKit;
|
||||
using MailKit;
|
||||
using MailKit.Security;
|
||||
using MailKit.Net.Pop3;
|
||||
using MailKit.Net.Imap;
|
||||
using MailKit.Net.Smtp;
|
||||
|
||||
using EmailValidation;
|
||||
@ -41,7 +39,7 @@ namespace bsmd.email
|
||||
{
|
||||
try
|
||||
{
|
||||
this.pop3Client = new Pop3Client();
|
||||
this.pop3Client = new Pop3Client(new MailKitLogger());
|
||||
this.pop3Client.ServerCertificateValidationCallback = ValidateServerCertificate;
|
||||
bool useSSL = true;
|
||||
this.pop3Client.Connect(Properties.Settings.Default.POP3Server, Properties.Settings.Default.POP3Port, useSSL);
|
||||
|
||||
41
nsw/Source/bsmd.email/MailKitLogger.cs
Normal file
41
nsw/Source/bsmd.email/MailKitLogger.cs
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright (c) 2021 Informatikbüro Daniel Schick
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
using log4net;
|
||||
using MailKit;
|
||||
|
||||
namespace bsmd.email
|
||||
{
|
||||
/// <summary>
|
||||
/// this class sends MailKit Log messages to Log4Net (hopefully :D)
|
||||
/// </summary>
|
||||
internal class MailKitLogger : IProtocolLogger
|
||||
{
|
||||
private readonly ILog _log = LogManager.GetLogger(typeof(BSMDImapClient));
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
// cleanup is done somewhere else
|
||||
}
|
||||
|
||||
public void LogClient(byte[] buffer, int offset, int count)
|
||||
{
|
||||
string logString = Encoding.Default.GetString(buffer, offset, count);
|
||||
_log.DebugFormat("C: {0}", logString);
|
||||
}
|
||||
|
||||
public void LogConnect(Uri uri)
|
||||
{
|
||||
_log.DebugFormat("Connecting to {0}", uri);
|
||||
}
|
||||
|
||||
public void LogServer(byte[] buffer, int offset, int count)
|
||||
{
|
||||
string logString = Encoding.Default.GetString(buffer, offset, count);
|
||||
_log.DebugFormat("S: {0}", logString);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,7 @@ namespace bsmd.email.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
@ -123,5 +123,41 @@ namespace bsmd.email.Properties {
|
||||
return ((int)(this["POP3Port"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("imap.strato.de")]
|
||||
public string IMAPServer {
|
||||
get {
|
||||
return ((string)(this["IMAPServer"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("993")]
|
||||
public int IMAPPort {
|
||||
get {
|
||||
return ((int)(this["IMAPPort"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("excel@textbausteine.net")]
|
||||
public string IMAPUser {
|
||||
get {
|
||||
return ((string)(this["IMAPUser"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("3kjasWss.;.")]
|
||||
public string IMAPPassword {
|
||||
get {
|
||||
return ((string)(this["IMAPPassword"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,5 +38,17 @@
|
||||
<Setting Name="POP3Port" Type="System.Int32" Scope="Application">
|
||||
<Value Profile="(Default)">995</Value>
|
||||
</Setting>
|
||||
<Setting Name="IMAPServer" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">imap.strato.de</Value>
|
||||
</Setting>
|
||||
<Setting Name="IMAPPort" Type="System.Int32" Scope="Application">
|
||||
<Value Profile="(Default)">993</Value>
|
||||
</Setting>
|
||||
<Setting Name="IMAPUser" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">excel@textbausteine.net</Value>
|
||||
</Setting>
|
||||
<Setting Name="IMAPPassword" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">3kjasWss.;.</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@ -45,6 +45,18 @@
|
||||
<setting name="POP3Port" serializeAs="String">
|
||||
<value>995</value>
|
||||
</setting>
|
||||
<setting name="IMAPServer" serializeAs="String">
|
||||
<value>imap.strato.de</value>
|
||||
</setting>
|
||||
<setting name="IMAPPort" serializeAs="String">
|
||||
<value>993</value>
|
||||
</setting>
|
||||
<setting name="IMAPUser" serializeAs="String">
|
||||
<value>excel@textbausteine.net</value>
|
||||
</setting>
|
||||
<setting name="IMAPPassword" serializeAs="String">
|
||||
<value>3kjasWss.;.</value>
|
||||
</setting>
|
||||
</bsmd.email.Properties.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
||||
@ -46,9 +46,8 @@
|
||||
<Reference Include="EmailValidation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=60f3df2f38e92638, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EmailValidation.1.0.4\lib\net45\EmailValidation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MailKit, Version=2.13.0.0, Culture=neutral, PublicKeyToken=4e064fe7c44a8f1b, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MailKit.2.13.0\lib\net45\MailKit.dll</HintPath>
|
||||
@ -60,9 +59,11 @@
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\netstandard1.1\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
@ -79,8 +80,10 @@
|
||||
<Compile Include="..\bsmd.database\Properties\AssemblyProjectKeyInfo.cs">
|
||||
<Link>Properties\AssemblyProjectKeyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="BSMDImapClient.cs" />
|
||||
<Compile Include="BSMDMail.cs" />
|
||||
<Compile Include="BSMDPopClient.cs" />
|
||||
<Compile Include="MailKitLogger.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
@ -91,6 +94,7 @@
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="..\bsmdKey.snk" />
|
||||
<None Include="bsmd.email.licenseheader" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
|
||||
13
nsw/Source/bsmd.email/bsmd.email.licenseheader
Normal file
13
nsw/Source/bsmd.email/bsmd.email.licenseheader
Normal file
@ -0,0 +1,13 @@
|
||||
extensions: designer.cs generated.cs
|
||||
extensions: .cs .cpp .h
|
||||
// Copyright (c) 2021 Informatikbüro Daniel Schick
|
||||
extensions: .aspx .ascx
|
||||
<%--
|
||||
Copyright (c) 2011 rubicon IT GmbH
|
||||
--%>
|
||||
extensions: .vb
|
||||
'Sample license text.
|
||||
extensions: .xml .config .xsd
|
||||
<!--
|
||||
Sample license text.
|
||||
-->
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="EmailValidation" version="1.0.4" targetFramework="net45" />
|
||||
<package id="log4net" version="2.0.8" targetFramework="net45" />
|
||||
<package id="log4net" version="2.0.12" targetFramework="net45" />
|
||||
<package id="MailKit" version="2.13.0" targetFramework="net45" />
|
||||
<package id="MimeKit" version="2.13.0" targetFramework="net45" />
|
||||
<package id="Portable.BouncyCastle" version="1.8.10" targetFramework="net45" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user