Skip to content

Commit ecd2d6a

Browse files
Merge pull request #9 from aspose-email-cloud/develop
Develop
2 parents b03a5b9 + 809671f commit ecd2d6a

File tree

291 files changed

+4988
-1036
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+4988
-1036
lines changed

Api/EmailApi.cs

Lines changed: 1412 additions & 80 deletions
Large diffs are not rendered by default.

Aspose.Email-Cloud.Tests/Tests/TestFixture.cs

Lines changed: 133 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public async Task OneTimeTearDown()
5555
if (folderExist.Exists == true && folderExist.IsFolder == true)
5656
{
5757
var deleteRequest = new DeleteFolderRequest(folder, StorageName, true);
58-
emailApi.DeleteFolder(deleteRequest);
58+
await emailApi.DeleteFolderAsync(deleteRequest);
5959
}
6060
}
6161

@@ -68,6 +68,7 @@ public async Task SyncTest()
6868
{
6969
var calendarFile = await CreateCalendar();
7070
var request = new GetCalendarRequest(calendarFile, folder, StorageName);
71+
// ReSharper disable once MethodHasAsyncOverload
7172
var calendar = emailApi.GetCalendar(request);
7273
Assert.AreEqual("CALENDAR", calendar.Name);
7374
}
@@ -285,7 +286,7 @@ await emailApi.UploadFileAsync(new UploadFileRequest($"{folder}/{fileName}", str
285286
$"{contactFile.FolderPath}/{contactFile.FileName}", contactFile.Storage)))
286287
using (var memoryStream = new MemoryStream())
287288
{
288-
contactFileStream.CopyTo(memoryStream);
289+
await contactFileStream.CopyToAsync(memoryStream);
289290
var contactFileContent = Encoding.UTF8.GetString(memoryStream.ToArray());
290291
Assert.True(contactFileContent.Contains("Thomas"));
291292
}
@@ -326,11 +327,11 @@ public async Task CreateCalendarEmailTest()
326327
{
327328
Attendees = new List<MailAddress>
328329
{
329-
new MailAddress("Attendee Name", "attendee@am.ru", "Accepted")
330+
new MailAddress("Attendee Name", "attendee@am.ru", "Accepted", null)
330331
},
331332
Description = "Some description",
332333
Summary = "Some summary",
333-
Organizer = new MailAddress("Organizer Name", "cloud.em@yandex.ru", null),
334+
Organizer = new MailAddress("Organizer Name", "cloud.em@yandex.ru", null, null),
334335
StartDate = DateTime.UtcNow.AddDays(1).AddHours(12),
335336
EndDate = DateTime.UtcNow.AddDays(1).AddHours(13),
336337
Location = "Some location"
@@ -350,9 +351,9 @@ await emailApi.SaveCalendarModelAsync(
350351
var email = new EmailDto
351352
{
352353
AlternateViews = new List<AlternateView> {alternate},
353-
From = new MailAddress("From address", "cloud.em@yandex.ru", "Accepted"),
354+
From = new MailAddress("From address", "cloud.em@yandex.ru", "Accepted", null),
354355
To = new List<MailAddress>
355-
{new MailAddress("To address", "cloud.em@yandex.ru", null)},
356+
{new MailAddress("To address", "cloud.em@yandex.ru", null, null)},
356357
Subject = "Some subject",
357358
Body = "Some body"
358359
};
@@ -544,6 +545,132 @@ await emailApi.SaveEmailClientMultiAccountAsync(
544545
multiAccountFromStorage.SendAccount.Credentials.Discriminator);
545546
}
546547

548+
[Test]
549+
[Pipeline]
550+
public async Task ConvertCalendarTest()
551+
{
552+
const string location = "Some location";
553+
//Create DTO with specified location:
554+
var calendarDto = new CalendarDto
555+
{
556+
Location = location,
557+
Summary = "Some summary",
558+
Description = "Some description",
559+
StartDate = DateTime.Today,
560+
EndDate = DateTime.Today.AddHours(1),
561+
Organizer = new MailAddress {Address = "organizer@aspose.com"},
562+
Attendees = new List<MailAddress>
563+
{new MailAddress {Address = "attendee@aspose.com"}}
564+
};
565+
//We can convert this DTO to a MAPI or ICS file stream:
566+
var mapiStream = await emailApi.ConvertCalendarModelToFileAsync(
567+
new ConvertCalendarModelToFileRequest(
568+
"Msg", calendarDto));
569+
/*
570+
//mapiStream can be saved as a calendar.msg file:
571+
using (var file = File.OpenWrite("calendar.msg"))
572+
{
573+
await mapiStream.CopyToAsync(file);
574+
}
575+
mapiStream.Seek(0, SeekOrigin.Begin);
576+
*/
577+
578+
//Let's convert this stream to an ICS file:
579+
var icsStream = await emailApi.ConvertCalendarAsync(new ConvertCalendarRequest(
580+
"Ics", mapiStream));
581+
/*
582+
//icsStream can be saved as a calendar.ics file:
583+
using (var file = File.OpenWrite("calendar.ics"))
584+
{
585+
await icsStream.CopyToAsync(file);
586+
}
587+
icsStream.Seek(0, SeekOrigin.Begin);
588+
*/
589+
590+
//ICS is a text format. We can convert the stream to a string and check that it
591+
//contains specified location as a substring:
592+
using (var memoryStream = new MemoryStream())
593+
{
594+
await icsStream.CopyToAsync(memoryStream);
595+
var icsString = Encoding.UTF8.GetString(memoryStream.ToArray());
596+
Assert.IsTrue(icsString.Contains(location));
597+
}
598+
599+
icsStream.Seek(0, SeekOrigin.Begin);
600+
//We can also convert a file stream back to a CalendarDto
601+
var dto = await emailApi.GetCalendarFileAsModelAsync(
602+
new GetCalendarFileAsModelRequest(icsStream));
603+
Assert.AreEqual(location, dto.Location);
604+
}
605+
606+
[Test]
607+
[Pipeline]
608+
public async Task ConvertContactTest()
609+
{
610+
const string surname = "Cane";
611+
var contactDto = new ContactDto
612+
{
613+
Gender = "Male",
614+
Surname = surname,
615+
GivenName = "John",
616+
EmailAddresses = new List<EmailAddress>
617+
{
618+
new EmailAddress {Address = "address@aspose.com"}
619+
},
620+
PhoneNumbers = new List<PhoneNumber>
621+
{
622+
new PhoneNumber {Number = "+47235345346"}
623+
}
624+
};
625+
var mapiStream = await emailApi.ConvertContactModelToFileAsync(
626+
new ConvertContactModelToFileRequest(
627+
"Msg", contactDto));
628+
var vcardStream = await emailApi.ConvertContactAsync(new ConvertContactRequest(
629+
"VCard", "Msg", mapiStream));
630+
using (var memoryStream = new MemoryStream())
631+
{
632+
await vcardStream.CopyToAsync(memoryStream);
633+
var vcardString = Encoding.UTF8.GetString(memoryStream.ToArray());
634+
Assert.IsTrue(vcardString.Contains(surname));
635+
}
636+
637+
vcardStream.Seek(0, SeekOrigin.Begin);
638+
var dto = await emailApi.GetContactFileAsModelAsync(
639+
new GetContactFileAsModelRequest("VCard", vcardStream));
640+
Assert.AreEqual(surname, dto.Surname);
641+
}
642+
643+
[Test]
644+
[Pipeline]
645+
public async Task ConvertEmailTest()
646+
{
647+
const string from = "from@aspose.com";
648+
var emailDto = new EmailDto
649+
{
650+
From = new MailAddress{Address = from},
651+
To = new List<MailAddress>{new MailAddress{Address = "to@aspose.com"}},
652+
Subject = "Some subject",
653+
Body = "Some body",
654+
Date = DateTime.MinValue.AddDays(1)
655+
};
656+
var mapiStream = await emailApi.ConvertEmailModelToFileAsync(
657+
new ConvertEmailModelToFileRequest(
658+
"Msg", emailDto));
659+
var emlStream = await emailApi.ConvertEmailAsync(new ConvertEmailRequest(
660+
"Eml", mapiStream));
661+
using (var memoryStream = new MemoryStream())
662+
{
663+
await emlStream.CopyToAsync(memoryStream);
664+
var emlString = Encoding.UTF8.GetString(memoryStream.ToArray());
665+
Assert.IsTrue(emlString.Contains(from));
666+
}
667+
668+
emlStream.Seek(0, SeekOrigin.Begin);
669+
var dto = await emailApi.GetEmailFileAsModelAsync(
670+
new GetEmailFileAsModelRequest(emlStream));
671+
Assert.AreEqual(from, dto.From.Address);
672+
}
673+
547674
private static string FileToBase64(string filePath)
548675
{
549676
var bytes = File.ReadAllBytes(filePath);

Aspose.Email-Cloud.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
<Title>Aspose.Email Cloud SDK for .NET</Title>
55
<TargetFrameworks>net452;netstandard2.0;net20;Xamarin.iOS10;Xamarin.Mac20;MonoAndroid60</TargetFrameworks>
66
<Description>Aspose.Email Cloud is a REST API for creating email applications that work with common email file formats. It lets developers manipulate message formats such as Outlook MSG, EML and MHT files.</Description>
7-
<Copyright>Copyright (c) 2002-2018 Aspose Pty Ltd</Copyright>
7+
<Copyright>Copyright (c) 2002-2020 Aspose Pty Ltd</Copyright>
88
<PackageProjectUrl>https://github.com/aspose-email-cloud/aspose-email-cloud-dotnet</PackageProjectUrl>
99
<License>MIT</License>
1010
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1111
<PackageIcon>aspose_email-for-cloud-icon.png</PackageIcon>
1212
<RepositoryUrl>https://github.com/aspose-email-cloud/aspose-email-cloud-dotnet</RepositoryUrl>
1313
<PackageTags>ASPOSE EMAIL CLOUD SDK Outlook MSG EML MHT</PackageTags>
1414
<RootNamespace>Aspose.Email.Cloud.Sdk</RootNamespace>
15-
<Version>20.3.0</Version>
15+
<Version>20.5.0.93</Version>
1616
<AndroidUseIntermediateDesignerFile>False</AndroidUseIntermediateDesignerFile>
1717
</PropertyGroup>
1818
<ItemGroup Condition=" '$(TargetFramework)' == 'Xamarin.iOS10' OR '$(TargetFramework)' == 'Xamarin.Mac20' OR '$(TargetFramework)' == 'MonoAndroid60'">

Model/AccountBaseRequest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright company="Aspose" file="AccountBaseRequest.cs">
3-
// Copyright (c) 2016 Aspose.Email for Cloud
3+
// Copyright (c) 2016-2020 Aspose.Email for Cloud
44
// </copyright>
55
// <summary>
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -38,12 +38,12 @@ namespace Aspose.Email.Cloud.Sdk.Model
3838
public class AccountBaseRequest
3939
{
4040
/// <summary>
41-
/// First account storage file name for receiving emails (or universal one)
41+
/// First account storage file name
4242
/// </summary>
4343
public string FirstAccount { get; set; }
4444

4545
/// <summary>
46-
/// Second account storage file name for sending emails (ignored if first is universal)
46+
/// Additional email account (for example, FirstAccount could be IMAP, and second one could be SMTP)
4747
/// </summary>
4848
public string SecondAccount { get; set; }
4949

@@ -56,8 +56,8 @@ public class AccountBaseRequest
5656
public AccountBaseRequest() {}
5757

5858
/// <summary>AccountBaseRequest constructor</summary>
59-
/// <param name="firstAccount">First account storage file name for receiving emails (or universal one) </param>
60-
/// <param name="secondAccount">Second account storage file name for sending emails (ignored if first is universal) </param>
59+
/// <param name="firstAccount">First account storage file name </param>
60+
/// <param name="secondAccount">Additional email account (for example, FirstAccount could be IMAP, and second one could be SMTP) </param>
6161
/// <param name="storageFolder">Storage folder location of account files </param>
6262
public AccountBaseRequest(string firstAccount, string secondAccount, StorageFolderLocation storageFolder)
6363
{

Model/AddAttachmentRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright company="Aspose" file="AddAttachmentRequest.cs">
3-
// Copyright (c) 2016 Aspose.Email for Cloud
3+
// Copyright (c) 2016-2020 Aspose.Email for Cloud
44
// </copyright>
55
// <summary>
66
// Permission is hereby granted, free of charge, to any person obtaining a copy

Model/AiBcrBase64Image.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright company="Aspose" file="AiBcrBase64Image.cs">
3-
// Copyright (c) 2016 Aspose.Email for Cloud
3+
// Copyright (c) 2016-2020 Aspose.Email for Cloud
44
// </copyright>
55
// <summary>
66
// Permission is hereby granted, free of charge, to any person obtaining a copy

Model/AiBcrBase64Rq.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright company="Aspose" file="AiBcrBase64Rq.cs">
3-
// Copyright (c) 2016 Aspose.Email for Cloud
3+
// Copyright (c) 2016-2020 Aspose.Email for Cloud
44
// </copyright>
55
// <summary>
66
// Permission is hereby granted, free of charge, to any person obtaining a copy

Model/AiBcrImage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright company="Aspose" file="AiBcrImage.cs">
3-
// Copyright (c) 2016 Aspose.Email for Cloud
3+
// Copyright (c) 2016-2020 Aspose.Email for Cloud
44
// </copyright>
55
// <summary>
66
// Permission is hereby granted, free of charge, to any person obtaining a copy

Model/AiBcrImageStorageFile.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright company="Aspose" file="AiBcrImageStorageFile.cs">
3-
// Copyright (c) 2016 Aspose.Email for Cloud
3+
// Copyright (c) 2016-2020 Aspose.Email for Cloud
44
// </copyright>
55
// <summary>
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -40,15 +40,15 @@ public class AiBcrImageStorageFile : AiBcrImage
4040
/// <summary>
4141
/// Image location
4242
/// </summary>
43-
public StorageFileLocation File { get; set; }
43+
public Object File { get; set; }
4444

4545
/// <summary>AiBcrImageStorageFile constructor</summary>
4646
public AiBcrImageStorageFile() {}
4747

4848
/// <summary>AiBcrImageStorageFile constructor</summary>
4949
/// <param name="isSingle">Determines that image contains single VCard or more. Ignored in current version. Multiple cards on image support will be added soon </param>
5050
/// <param name="file">Image location </param>
51-
public AiBcrImageStorageFile(bool? isSingle, StorageFileLocation file)
51+
public AiBcrImageStorageFile(bool? isSingle, Object file)
5252
{
5353
IsSingle = isSingle;
5454
File = file;

Model/AiBcrOcrData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright company="Aspose" file="AiBcrOcrData.cs">
3-
// Copyright (c) 2016 Aspose.Email for Cloud
3+
// Copyright (c) 2016-2020 Aspose.Email for Cloud
44
// </copyright>
55
// <summary>
66
// Permission is hereby granted, free of charge, to any person obtaining a copy

0 commit comments

Comments
 (0)