diff --git a/MailComponent/Mail/InternetMailAttachment.cs b/MailComponent/Mail/InternetMailAttachment.cs index 06d2d8c..ec95d45 100644 --- a/MailComponent/Mail/InternetMailAttachment.cs +++ b/MailComponent/Mail/InternetMailAttachment.cs @@ -17,12 +17,28 @@ namespace OneScript.InternetMail [ContextClass("ИнтернетПочтовоеВложение", "InternetMailAttachment")] public class InternetMailAttachment : AutoContext { + /// + /// Пустое почтовое вложение + /// public InternetMailAttachment() { EncodingMode = InternetMailAttachmentEncodingMode.Mime; Data = ValueFactory.Create(); } + /// + /// Почтовое вложение на основании BinaryDataContext + /// + public InternetMailAttachment(BinaryDataContext binaryData, string fileName = "") + { + EncodingMode = InternetMailAttachmentEncodingMode.Mime; + Data = binaryData; + FileName = fileName; + } + + /// + /// Почтовое вложение на основании файла + /// public InternetMailAttachment(string fileName) { EncodingMode = InternetMailAttachmentEncodingMode.Mime; diff --git a/MailComponent/Mail/InternetMailAttachments.cs b/MailComponent/Mail/InternetMailAttachments.cs index 7b2b9a3..c51473c 100644 --- a/MailComponent/Mail/InternetMailAttachments.cs +++ b/MailComponent/Mail/InternetMailAttachments.cs @@ -60,8 +60,7 @@ public InternetMailAttachment Add(string filePath, string attachmentName = "") public InternetMailAttachment Add(BinaryDataContext data, string attachmentName = "") { - var attachment = new InternetMailAttachment(); - attachment.Data = data; + var attachment = new InternetMailAttachment(data, attachmentName); attachment.Name = attachmentName; _data.Add(attachment); return attachment; diff --git a/MailComponent/Mail/InternetMailMessage.cs b/MailComponent/Mail/InternetMailMessage.cs index 764b24d..502cfde 100644 --- a/MailComponent/Mail/InternetMailMessage.cs +++ b/MailComponent/Mail/InternetMailMessage.cs @@ -94,6 +94,7 @@ public InternetMailMessage(MailKit.IMessageSummary headers) : this(GenerateHeade public InternetMailMessage(MimeMessage nativeMessage, string identifier) : this(nativeMessage.Headers) { + Uid.Add(ValueFactory.Create(identifier)); if (nativeMessage.Body is TextPart) { @@ -101,6 +102,7 @@ public InternetMailMessage(MimeMessage nativeMessage, string identifier) : this( } else if (nativeMessage.Body is Multipart) { + var body = nativeMessage.Body as Multipart; foreach (var part in body) { @@ -125,6 +127,17 @@ public InternetMailMessage(MimeMessage nativeMessage, string identifier) : this( } } } + + foreach (var attachment in nativeMessage.Attachments) + { + var part = (MimePart)attachment; + var fileName = part.FileName; + var stream = new MemoryStream(); + + part.ContentObject.DecodeTo(stream); + BinaryDataContext bin = new BinaryDataContext(stream.ToArray()); + Attachments.Add(bin, fileName); + } } /// @@ -255,7 +268,6 @@ public InternetMailMessage(MimeMessage nativeMessage, string identifier) : this( /// /// Смещение даты отправления от универсального времени (UTC) в секундах. Для часовых поясов, отстающих от UTC, значение отрицательное. - /// Пример приведения даты отправления к дате в часовом поясе сеанса: /// ДатаОтправленияВЗонеОтправителя = Сообщение.ДатаОтправления;  /// diff --git a/MailComponent/Mail/InternetMailMessageImportance.cs b/MailComponent/Mail/InternetMailMessageImportance.cs index fac6457..3f7d1fc 100644 --- a/MailComponent/Mail/InternetMailMessageImportance.cs +++ b/MailComponent/Mail/InternetMailMessageImportance.cs @@ -5,7 +5,6 @@ This Source Code Form is subject to the terms of the at http://mozilla.org/MPL/2.0/. ----------------------------------------------------------*/ using System; -using ScriptEngine.Machine.Contexts; using ScriptEngine; namespace OneScript.InternetMail diff --git a/MailComponent/Mail/Pop3Receiver.cs b/MailComponent/Mail/Pop3Receiver.cs index a841573..60482ed 100755 --- a/MailComponent/Mail/Pop3Receiver.cs +++ b/MailComponent/Mail/Pop3Receiver.cs @@ -153,13 +153,16 @@ public ArrayImpl Get(bool deleteMessages, ArrayImpl ids, bool markAsRead) throw RuntimeException.InvalidArgumentValue(); // TODO: Внятное сообщение var result = new ArrayImpl(); + var processedMessages = GetMessagesList(ids); foreach (var i in processedMessages) { var mimeMessage = client.GetMessage(i); + var iMessage = new InternetMailMessage(mimeMessage, client.GetMessageUid(i)); result.Add(iMessage); + } if (deleteMessages && processedMessages.Count > 0) diff --git a/MailComponent/MailComponent.csproj b/MailComponent/MailComponent.csproj index 57e9c81..60972d9 100644 --- a/MailComponent/MailComponent.csproj +++ b/MailComponent/MailComponent.csproj @@ -1,4 +1,4 @@ - + Debug @@ -7,7 +7,7 @@ Library OneScript.InternetMail MailComponent - v4.5 + v4.5.2 true @@ -30,6 +30,15 @@ false + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + + + ..\packages\OneScript.1.0.19\lib\net452\ScriptEngine.dll + + + ..\packages\OneScript.StandardLibrary.1.0.19\lib\net452\ScriptEngine.HostedScript.dll + ..\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll @@ -43,15 +52,6 @@ ..\packages\MimeKit.1.10.0\lib\net45\MimeKit.dll - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - - - ..\packages\OneScript.StandardLibrary.1.0.15\lib\net40\ScriptEngine.HostedScript.dll - - - ..\packages\OneScript.1.0.15\lib\net40\ScriptEngine.dll - ..\packages\MailKit.1.10.1\lib\net45\MailKit.dll diff --git a/MailComponent/Properties/AssemblyInfo.cs b/MailComponent/Properties/AssemblyInfo.cs index 2ce6d5c..3de9d5b 100755 --- a/MailComponent/Properties/AssemblyInfo.cs +++ b/MailComponent/Properties/AssemblyInfo.cs @@ -1,5 +1,10 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +/*---------------------------------------------------------- +This Source Code Form is subject to the terms of the +Mozilla Public License, v.2.0. If a copy of the MPL +was not distributed with this file, You can obtain one +at http://mozilla.org/MPL/2.0/. +----------------------------------------------------------*/ +using System.Reflection; // Information about this assembly is defined by the following attributes. // Change them to the values specific to your project. diff --git a/MailComponent/packages.config b/MailComponent/packages.config index 84b4a4f..6a8403e 100755 --- a/MailComponent/packages.config +++ b/MailComponent/packages.config @@ -4,7 +4,7 @@ - - - + + + \ No newline at end of file diff --git a/NUnitTests/EngineHelpWrapper.cs b/NUnitTests/EngineHelpWrapper.cs index 0a055d2..547f898 100755 --- a/NUnitTests/EngineHelpWrapper.cs +++ b/NUnitTests/EngineHelpWrapper.cs @@ -1,6 +1,11 @@ -using System; +/*---------------------------------------------------------- +This Source Code Form is subject to the terms of the +Mozilla Public License, v.2.0. If a copy of the MPL +was not distributed with this file, You can obtain one +at http://mozilla.org/MPL/2.0/. +----------------------------------------------------------*/ +using System; using System.IO; -using NUnit.Framework; using ScriptEngine.Machine.Contexts; using ScriptEngine.HostedScript.Library; using ScriptEngine.Machine; diff --git a/NUnitTests/MainTestClass.cs b/NUnitTests/MainTestClass.cs index 6575859..64b7d73 100755 --- a/NUnitTests/MainTestClass.cs +++ b/NUnitTests/MainTestClass.cs @@ -1,9 +1,10 @@ -using System; -using System.IO; +/*---------------------------------------------------------- +This Source Code Form is subject to the terms of the +Mozilla Public License, v.2.0. If a copy of the MPL +was not distributed with this file, You can obtain one +at http://mozilla.org/MPL/2.0/. +----------------------------------------------------------*/ using NUnit.Framework; -using ScriptEngine.HostedScript; -using ScriptEngine.Machine; -using ScriptEngine.Environment; using OneScript.InternetMail; // Используется NUnit 3.6 diff --git a/NUnitTests/NUnitTests.csproj b/NUnitTests/NUnitTests.csproj index eaf4bce..75fe88e 100755 --- a/NUnitTests/NUnitTests.csproj +++ b/NUnitTests/NUnitTests.csproj @@ -1,4 +1,4 @@ - + Debug @@ -7,7 +7,7 @@ Library NUnitTests NUnitTests - v4.5 + v4.5.2 true @@ -25,6 +25,15 @@ 4 + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + + + ..\packages\OneScript.1.0.19\lib\net452\ScriptEngine.dll + + + ..\packages\OneScript.StandardLibrary.1.0.19\lib\net452\ScriptEngine.HostedScript.dll + ..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll @@ -32,15 +41,6 @@ ..\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - - - ..\packages\OneScript.StandardLibrary.1.0.15\lib\net40\ScriptEngine.HostedScript.dll - - - ..\packages\OneScript.1.0.15\lib\net40\ScriptEngine.dll - @@ -51,7 +51,7 @@ - + @@ -60,4 +60,4 @@ - + \ No newline at end of file diff --git a/NUnitTests/Tests/external.os b/NUnitTests/Tests/external.os index fcece94..657910e 100755 --- a/NUnitTests/Tests/external.os +++ b/NUnitTests/Tests/external.os @@ -1,4 +1,10 @@ -Перем юТест; +//---------------------------------------------------------- +//This Source Code Form is subject to the terms of the +//Mozilla Public License, v.2.0. If a copy of the MPL +//was not distributed with this file, You can obtain one +//at http://mozilla.org/MPL/2.0/. +//---------------------------------------------------------- +Перем юТест; //////////////////////////////////////////////////////////////////// // Программный интерфейс diff --git a/NUnitTests/packages.config b/NUnitTests/packages.config index 6532a1b..b7070ba 100755 --- a/NUnitTests/packages.config +++ b/NUnitTests/packages.config @@ -1,8 +1,8 @@  - + - - + + \ No newline at end of file diff --git a/TestApp/Program.cs b/TestApp/Program.cs index d7fc1fb..46672c0 100755 --- a/TestApp/Program.cs +++ b/TestApp/Program.cs @@ -1,4 +1,10 @@ -using System; +/*---------------------------------------------------------- +This Source Code Form is subject to the terms of the +Mozilla Public License, v.2.0. If a copy of the MPL +was not distributed with this file, You can obtain one +at http://mozilla.org/MPL/2.0/. +----------------------------------------------------------*/ +using System; using System.IO; using ScriptEngine.Machine; using ScriptEngine.HostedScript; diff --git a/TestApp/Properties/AssemblyInfo.cs b/TestApp/Properties/AssemblyInfo.cs index 0b73595..2d62091 100755 --- a/TestApp/Properties/AssemblyInfo.cs +++ b/TestApp/Properties/AssemblyInfo.cs @@ -1,5 +1,10 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +/*---------------------------------------------------------- +This Source Code Form is subject to the terms of the +Mozilla Public License, v.2.0. If a copy of the MPL +was not distributed with this file, You can obtain one +at http://mozilla.org/MPL/2.0/. +----------------------------------------------------------*/ +using System.Reflection; // Information about this assembly is defined by the following attributes. // Change them to the values specific to your project. diff --git a/TestApp/TestApp.csproj b/TestApp/TestApp.csproj index 43e4663..69d4190 100755 --- a/TestApp/TestApp.csproj +++ b/TestApp/TestApp.csproj @@ -1,4 +1,4 @@ - + Debug @@ -7,7 +7,7 @@ Exe TestApp TestApp - v4.5 + v4.5.2 true @@ -27,20 +27,20 @@ true + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + + + ..\packages\OneScript.1.0.19\lib\net452\ScriptEngine.dll + + + ..\packages\OneScript.StandardLibrary.1.0.19\lib\net452\ScriptEngine.HostedScript.dll + ..\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - - - ..\packages\OneScript.StandardLibrary.1.0.15\lib\net40\ScriptEngine.HostedScript.dll - - - ..\packages\OneScript.1.0.15\lib\net40\ScriptEngine.dll - diff --git a/TestApp/TestSendReceive.os b/TestApp/TestSendReceive.os index 9dce1ae..54bc72e 100755 --- a/TestApp/TestSendReceive.os +++ b/TestApp/TestSendReceive.os @@ -1,4 +1,10 @@ -Функция СоздатьПрофиль(Знач SMTP = Истина, Знач POP3 = Истина, Знач IMAP = Истина) +//---------------------------------------------------------- +//This Source Code Form is subject to the terms of the +//Mozilla Public License, v.2.0. If a copy of the MPL +//was not distributed with this file, You can obtain one +//at http://mozilla.org/MPL/2.0/. +//---------------------------------------------------------- +Функция СоздатьПрофиль(Знач SMTP = Истина, Знач POP3 = Истина, Знач IMAP = Истина) Профиль = Новый ИнтернетПочтовыйПрофиль; diff --git a/TestApp/packages.config b/TestApp/packages.config index 82fed5f..1582357 100755 --- a/TestApp/packages.config +++ b/TestApp/packages.config @@ -1,7 +1,7 @@  - - - + + + \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 857ab42..5ec4177 100755 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 1.0.4-{build} +version: 1.0.5-{build} image: Visual Studio 2017 environment: main_project: MailComponent diff --git a/packagedef b/packagedef index bfa6ce0..f31ee81 100755 --- a/packagedef +++ b/packagedef @@ -4,11 +4,11 @@ // Описание.Имя("InternetMail") - .Версия("1.0.4") + .Версия("1.0.5") .Автор("Батанов Сергей") .АдресАвтора("sergey.batanov@dmpas.ru") .Описание("Реализация стандартных объектов из раздела ИнтернетПочта") - .ВерсияСреды("1.0.15") + .ВерсияСреды("1.0.19") .ВключитьФайл("bin") .ВключитьФайл("README.md") .ВключитьФайл("package-loader.os")