Skip to content

Commit 11e81fd

Browse files
authored
Merge pull request #14 from dmpas/develop
1.0.5
2 parents a1b5967 + 47ec773 commit 11e81fd

20 files changed

+128
-65
lines changed

MailComponent/Mail/InternetMailAttachment.cs

+16
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,28 @@ namespace OneScript.InternetMail
1717
[ContextClass("ИнтернетПочтовоеВложение", "InternetMailAttachment")]
1818
public class InternetMailAttachment : AutoContext<InternetMailAttachment>
1919
{
20+
/// <summary>
21+
/// Пустое почтовое вложение
22+
/// </summary>
2023
public InternetMailAttachment()
2124
{
2225
EncodingMode = InternetMailAttachmentEncodingMode.Mime;
2326
Data = ValueFactory.Create();
2427
}
2528

29+
/// <summary>
30+
/// Почтовое вложение на основании BinaryDataContext
31+
/// </summary>
32+
public InternetMailAttachment(BinaryDataContext binaryData, string fileName = "")
33+
{
34+
EncodingMode = InternetMailAttachmentEncodingMode.Mime;
35+
Data = binaryData;
36+
FileName = fileName;
37+
}
38+
39+
/// <summary>
40+
/// Почтовое вложение на основании файла
41+
/// </summary>
2642
public InternetMailAttachment(string fileName)
2743
{
2844
EncodingMode = InternetMailAttachmentEncodingMode.Mime;

MailComponent/Mail/InternetMailAttachments.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ public InternetMailAttachment Add(string filePath, string attachmentName = "")
6060

6161
public InternetMailAttachment Add(BinaryDataContext data, string attachmentName = "")
6262
{
63-
var attachment = new InternetMailAttachment();
64-
attachment.Data = data;
63+
var attachment = new InternetMailAttachment(data, attachmentName);
6564
attachment.Name = attachmentName;
6665
_data.Add(attachment);
6766
return attachment;

MailComponent/Mail/InternetMailMessage.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,15 @@ public InternetMailMessage(MailKit.IMessageSummary headers) : this(GenerateHeade
9494

9595
public InternetMailMessage(MimeMessage nativeMessage, string identifier) : this(nativeMessage.Headers)
9696
{
97+
9798
Uid.Add(ValueFactory.Create(identifier));
9899
if (nativeMessage.Body is TextPart)
99100
{
100101
Texts.Add(new InternetMailText(nativeMessage.Body as TextPart));
101102
}
102103
else if (nativeMessage.Body is Multipart)
103104
{
105+
104106
var body = nativeMessage.Body as Multipart;
105107
foreach (var part in body)
106108
{
@@ -125,6 +127,17 @@ public InternetMailMessage(MimeMessage nativeMessage, string identifier) : this(
125127
}
126128
}
127129
}
130+
131+
foreach (var attachment in nativeMessage.Attachments)
132+
{
133+
var part = (MimePart)attachment;
134+
var fileName = part.FileName;
135+
var stream = new MemoryStream();
136+
137+
part.ContentObject.DecodeTo(stream);
138+
BinaryDataContext bin = new BinaryDataContext(stream.ToArray());
139+
Attachments.Add(bin, fileName);
140+
}
128141
}
129142

130143
/// <summary>
@@ -255,7 +268,6 @@ public InternetMailMessage(MimeMessage nativeMessage, string identifier) : this(
255268

256269
/// <summary>
257270
/// Смещение даты отправления от универсального времени (UTC) в секундах. Для часовых поясов, отстающих от UTC, значение отрицательное.
258-
259271
/// Пример приведения даты отправления к дате в часовом поясе сеанса:
260272
/// ДатаОтправленияВЗонеОтправителя = Сообщение.ДатаОтправления; 
261273
/// <code>

MailComponent/Mail/InternetMailMessageImportance.cs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ This Source Code Form is subject to the terms of the
55
at http://mozilla.org/MPL/2.0/.
66
----------------------------------------------------------*/
77
using System;
8-
using ScriptEngine.Machine.Contexts;
98
using ScriptEngine;
109

1110
namespace OneScript.InternetMail

MailComponent/Mail/Pop3Receiver.cs

+3
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,16 @@ public ArrayImpl Get(bool deleteMessages, ArrayImpl ids, bool markAsRead)
153153
throw RuntimeException.InvalidArgumentValue(); // TODO: Внятное сообщение
154154

155155
var result = new ArrayImpl();
156+
156157
var processedMessages = GetMessagesList(ids);
157158

158159
foreach (var i in processedMessages)
159160
{
160161
var mimeMessage = client.GetMessage(i);
162+
161163
var iMessage = new InternetMailMessage(mimeMessage, client.GetMessageUid(i));
162164
result.Add(iMessage);
165+
163166
}
164167

165168
if (deleteMessages && processedMessages.Count > 0)

MailComponent/MailComponent.csproj

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -7,7 +7,7 @@
77
<OutputType>Library</OutputType>
88
<RootNamespace>OneScript.InternetMail</RootNamespace>
99
<AssemblyName>MailComponent</AssemblyName>
10-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
10+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1111
</PropertyGroup>
1212
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1313
<DebugSymbols>true</DebugSymbols>
@@ -30,6 +30,15 @@
3030
<ConsolePause>false</ConsolePause>
3131
</PropertyGroup>
3232
<ItemGroup>
33+
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
34+
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
35+
</Reference>
36+
<Reference Include="ScriptEngine, Version=1.0.19.104, Culture=neutral, PublicKeyToken=null">
37+
<HintPath>..\packages\OneScript.1.0.19\lib\net452\ScriptEngine.dll</HintPath>
38+
</Reference>
39+
<Reference Include="ScriptEngine.HostedScript, Version=1.0.19.104, Culture=neutral, PublicKeyToken=null">
40+
<HintPath>..\packages\OneScript.StandardLibrary.1.0.19\lib\net452\ScriptEngine.HostedScript.dll</HintPath>
41+
</Reference>
3342
<Reference Include="System" />
3443
<Reference Include="DotNetZip">
3544
<HintPath>..\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll</HintPath>
@@ -43,15 +52,6 @@
4352
<Reference Include="MimeKit">
4453
<HintPath>..\packages\MimeKit.1.10.0\lib\net45\MimeKit.dll</HintPath>
4554
</Reference>
46-
<Reference Include="Newtonsoft.Json">
47-
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
48-
</Reference>
49-
<Reference Include="ScriptEngine.HostedScript">
50-
<HintPath>..\packages\OneScript.StandardLibrary.1.0.15\lib\net40\ScriptEngine.HostedScript.dll</HintPath>
51-
</Reference>
52-
<Reference Include="ScriptEngine">
53-
<HintPath>..\packages\OneScript.1.0.15\lib\net40\ScriptEngine.dll</HintPath>
54-
</Reference>
5555
<Reference Include="MailKit">
5656
<HintPath>..\packages\MailKit.1.10.1\lib\net45\MailKit.dll</HintPath>
5757
</Reference>

MailComponent/Properties/AssemblyInfo.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
using System.Reflection;
2-
using System.Runtime.CompilerServices;
1+
/*----------------------------------------------------------
2+
This Source Code Form is subject to the terms of the
3+
Mozilla Public License, v.2.0. If a copy of the MPL
4+
was not distributed with this file, You can obtain one
5+
at http://mozilla.org/MPL/2.0/.
6+
----------------------------------------------------------*/
7+
using System.Reflection;
38

49
// Information about this assembly is defined by the following attributes.
510
// Change them to the values specific to your project.

MailComponent/packages.config

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<package id="DotNetZip" version="1.10.1" targetFramework="net45" />
55
<package id="MailKit" version="1.10.1" targetFramework="net45" />
66
<package id="MimeKit" version="1.10.0" targetFramework="net45" />
7-
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
8-
<package id="OneScript" version="1.0.15" targetFramework="net45" />
9-
<package id="OneScript.StandardLibrary" version="1.0.15" targetFramework="net45" />
7+
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
8+
<package id="OneScript" version="1.0.19" targetFramework="net452" />
9+
<package id="OneScript.StandardLibrary" version="1.0.19" targetFramework="net452" />
1010
</packages>

NUnitTests/EngineHelpWrapper.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
using System;
1+
/*----------------------------------------------------------
2+
This Source Code Form is subject to the terms of the
3+
Mozilla Public License, v.2.0. If a copy of the MPL
4+
was not distributed with this file, You can obtain one
5+
at http://mozilla.org/MPL/2.0/.
6+
----------------------------------------------------------*/
7+
using System;
28
using System.IO;
3-
using NUnit.Framework;
49
using ScriptEngine.Machine.Contexts;
510
using ScriptEngine.HostedScript.Library;
611
using ScriptEngine.Machine;

NUnitTests/MainTestClass.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
using System;
2-
using System.IO;
1+
/*----------------------------------------------------------
2+
This Source Code Form is subject to the terms of the
3+
Mozilla Public License, v.2.0. If a copy of the MPL
4+
was not distributed with this file, You can obtain one
5+
at http://mozilla.org/MPL/2.0/.
6+
----------------------------------------------------------*/
37
using NUnit.Framework;
4-
using ScriptEngine.HostedScript;
5-
using ScriptEngine.Machine;
6-
using ScriptEngine.Environment;
78
using OneScript.InternetMail;
89

910
// Используется NUnit 3.6

NUnitTests/NUnitTests.csproj

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -7,7 +7,7 @@
77
<OutputType>Library</OutputType>
88
<RootNamespace>NUnitTests</RootNamespace>
99
<AssemblyName>NUnitTests</AssemblyName>
10-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
10+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1111
</PropertyGroup>
1212
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1313
<DebugSymbols>true</DebugSymbols>
@@ -25,22 +25,22 @@
2525
<WarningLevel>4</WarningLevel>
2626
</PropertyGroup>
2727
<ItemGroup>
28+
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
29+
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
30+
</Reference>
31+
<Reference Include="ScriptEngine, Version=1.0.19.104, Culture=neutral, PublicKeyToken=null">
32+
<HintPath>..\packages\OneScript.1.0.19\lib\net452\ScriptEngine.dll</HintPath>
33+
</Reference>
34+
<Reference Include="ScriptEngine.HostedScript, Version=1.0.19.104, Culture=neutral, PublicKeyToken=null">
35+
<HintPath>..\packages\OneScript.StandardLibrary.1.0.19\lib\net452\ScriptEngine.HostedScript.dll</HintPath>
36+
</Reference>
2837
<Reference Include="System" />
2938
<Reference Include="nunit.framework">
3039
<HintPath>..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll</HintPath>
3140
</Reference>
3241
<Reference Include="DotNetZip">
3342
<HintPath>..\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll</HintPath>
3443
</Reference>
35-
<Reference Include="Newtonsoft.Json">
36-
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
37-
</Reference>
38-
<Reference Include="ScriptEngine.HostedScript">
39-
<HintPath>..\packages\OneScript.StandardLibrary.1.0.15\lib\net40\ScriptEngine.HostedScript.dll</HintPath>
40-
</Reference>
41-
<Reference Include="ScriptEngine">
42-
<HintPath>..\packages\OneScript.1.0.15\lib\net40\ScriptEngine.dll</HintPath>
43-
</Reference>
4444
</ItemGroup>
4545
<ItemGroup>
4646
<Compile Include="EngineHelpWrapper.cs" />
@@ -51,7 +51,7 @@
5151
</ItemGroup>
5252
<ItemGroup>
5353
<EmbeddedResource Include="Tests\testrunner.os" />
54-
<EmbeddedResource Include="Tests\external.os" />
54+
<EmbeddedResource Include="Tests\external.os" />
5555
</ItemGroup>
5656
<ItemGroup>
5757
<ProjectReference Include="..\MailComponent\MailComponent.csproj">
@@ -60,4 +60,4 @@
6060
</ProjectReference>
6161
</ItemGroup>
6262
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
63-
</Project>
63+
</Project>

NUnitTests/Tests/external.os

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
Перем юТест;
1+
//----------------------------------------------------------
2+
//This Source Code Form is subject to the terms of the
3+
//Mozilla Public License, v.2.0. If a copy of the MPL
4+
//was not distributed with this file, You can obtain one
5+
//at http://mozilla.org/MPL/2.0/.
6+
//----------------------------------------------------------
7+
Перем юТест;
28

39
////////////////////////////////////////////////////////////////////
410
// Программный интерфейс

NUnitTests/packages.config

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="DotNetZip" version="1.10.1" targetFramework="net45" />
4-
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
4+
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
55
<package id="NUnit" version="3.4.1" targetFramework="net45" />
6-
<package id="OneScript" version="1.0.15" targetFramework="net45" />
7-
<package id="OneScript.StandardLibrary" version="1.0.15" targetFramework="net45" />
6+
<package id="OneScript" version="1.0.19" targetFramework="net452" />
7+
<package id="OneScript.StandardLibrary" version="1.0.19" targetFramework="net452" />
88
</packages>

TestApp/Program.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
using System;
1+
/*----------------------------------------------------------
2+
This Source Code Form is subject to the terms of the
3+
Mozilla Public License, v.2.0. If a copy of the MPL
4+
was not distributed with this file, You can obtain one
5+
at http://mozilla.org/MPL/2.0/.
6+
----------------------------------------------------------*/
7+
using System;
28
using System.IO;
39
using ScriptEngine.Machine;
410
using ScriptEngine.HostedScript;

TestApp/Properties/AssemblyInfo.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
using System.Reflection;
2-
using System.Runtime.CompilerServices;
1+
/*----------------------------------------------------------
2+
This Source Code Form is subject to the terms of the
3+
Mozilla Public License, v.2.0. If a copy of the MPL
4+
was not distributed with this file, You can obtain one
5+
at http://mozilla.org/MPL/2.0/.
6+
----------------------------------------------------------*/
7+
using System.Reflection;
38

49
// Information about this assembly is defined by the following attributes.
510
// Change them to the values specific to your project.

TestApp/TestApp.csproj

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -7,7 +7,7 @@
77
<OutputType>Exe</OutputType>
88
<RootNamespace>TestApp</RootNamespace>
99
<AssemblyName>TestApp</AssemblyName>
10-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
10+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1111
</PropertyGroup>
1212
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1313
<DebugSymbols>true</DebugSymbols>
@@ -27,20 +27,20 @@
2727
<ExternalConsole>true</ExternalConsole>
2828
</PropertyGroup>
2929
<ItemGroup>
30+
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
31+
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
32+
</Reference>
33+
<Reference Include="ScriptEngine, Version=1.0.19.104, Culture=neutral, PublicKeyToken=null">
34+
<HintPath>..\packages\OneScript.1.0.19\lib\net452\ScriptEngine.dll</HintPath>
35+
</Reference>
36+
<Reference Include="ScriptEngine.HostedScript, Version=1.0.19.104, Culture=neutral, PublicKeyToken=null">
37+
<HintPath>..\packages\OneScript.StandardLibrary.1.0.19\lib\net452\ScriptEngine.HostedScript.dll</HintPath>
38+
</Reference>
3039
<Reference Include="System" />
3140
<Reference Include="DotNetZip">
3241
<HintPath>..\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll</HintPath>
3342
</Reference>
3443
<Reference Include="System.Configuration" />
35-
<Reference Include="Newtonsoft.Json">
36-
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
37-
</Reference>
38-
<Reference Include="ScriptEngine.HostedScript">
39-
<HintPath>..\packages\OneScript.StandardLibrary.1.0.15\lib\net40\ScriptEngine.HostedScript.dll</HintPath>
40-
</Reference>
41-
<Reference Include="ScriptEngine">
42-
<HintPath>..\packages\OneScript.1.0.15\lib\net40\ScriptEngine.dll</HintPath>
43-
</Reference>
4444
</ItemGroup>
4545
<ItemGroup>
4646
<Compile Include="Program.cs" />

TestApp/TestSendReceive.os

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
Функция СоздатьПрофиль(Знач SMTP = Истина, Знач POP3 = Истина, Знач IMAP = Истина)
1+
//----------------------------------------------------------
2+
//This Source Code Form is subject to the terms of the
3+
//Mozilla Public License, v.2.0. If a copy of the MPL
4+
//was not distributed with this file, You can obtain one
5+
//at http://mozilla.org/MPL/2.0/.
6+
//----------------------------------------------------------
7+
Функция СоздатьПрофиль(Знач SMTP = Истина, Знач POP3 = Истина, Знач IMAP = Истина)
28

39
Профиль = Новый ИнтернетПочтовыйПрофиль;
410

TestApp/packages.config

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="DotNetZip" version="1.10.1" targetFramework="net45" />
4-
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
5-
<package id="OneScript" version="1.0.15" targetFramework="net45" />
6-
<package id="OneScript.StandardLibrary" version="1.0.15" targetFramework="net45" />
4+
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
5+
<package id="OneScript" version="1.0.19" targetFramework="net452" />
6+
<package id="OneScript.StandardLibrary" version="1.0.19" targetFramework="net452" />
77
</packages>

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 1.0.4-{build}
1+
version: 1.0.5-{build}
22
image: Visual Studio 2017
33
environment:
44
main_project: MailComponent

0 commit comments

Comments
 (0)