Browse our Products

Aspose.Email for .NET 21.9 Release Notes

All Changes

KeySummaryCategory
EMAILNET-40410PST to MSG: Some messages extraction slowEnhancement
EMAILNET-40303Custom flags generated with ImapMessageFlag.Keyword function contains extra flagsBug
EMAILNET-40397Loading MAPI message from stream throws InvalidOperationExceptionBug
EMAILNET-40335IGraphClient.ListFolders method returns 10 first foldersBug
EMAILNET-40411Inline attachments in EML file are not showingBug
EMAILNET-40325IGraphClient.ListFolders method returns empty arrayBug
EMAILNET-40383Ignoring SMTP address check throws SmtpExceptionBug
EMAILNET-40220Loading Appointment throws AsposeArgumentOutOfRangeExceptionBug
EMAILNET-40402Calendar event does not repeat with UNTIL property in recurrence ruleBug
EMAILNET-40401deepClone losing the multipart/alternativeBug
EMAILNET-40403Date from EML is not shown properlyBug
EMAILNET-40347ImapMessageInfo.Headers collection is always emptyBug

New Features

Support for asynchronous operations by EWSClient

Asynchronous methods have been added to the EWSClient.

Unlike the synchronous methods, the asynchronous methods are non-blocking and allow to perform multiple requests simultaneously. Asynchronous methods are named with the Async postfix.

Note: Async methods are available in versions targeting .NET Core, .NET Framework 4.5, and later.

IAsyncEwsClient code examples

Using IAsyncTokenProvider to get OAuth tokens asynchronously

private class SomeAsyncTokenProvider : IAsyncTokenProvider
{
    public SomeAsyncTokenProvider( /*some parameters*/)
    {
        ...
    }

    public async Task<OAuthToken> GetAccessTokenAsync(bool ignoreExistingToken = false,
        CancellationToken cancellationToken = default)
    {
        //Some asynchronous code to get a valid OAuthToken
        ...
    }

    public void Dispose()
    {
        ...
    }
}

Create the IAsyncEwsClientInstance

//The cancellationToken can be used
var cancellationToken = new CancellationToken();

//Create IAsyncEwsClientInstance
IAsyncTokenProvider tokenProvider = new SomeAsyncTokenProvider(/*some parameters*/);
const string mailboxUri = "https://outlook.office365.com/ews/exchange.asmx";
var ewsClient = await EWSClient.GetEwsClientAsync(mailboxUri, new OAuthNetworkCredential(tokenProvider),
    cancellationToken: cancellationToken);

Send message

MailMessage message = new MailMessage("from@aspose.com", "to@aspose.com", "Some subject", "Some body");
await ewsClient.SendAsync(message, cancellationToken: cancellationToken);

Fetch message with attachments

var fetched = await ewsClient.FetchItemAsync(messageUri, cancellationToken: cancellationToken);

Append messages

IEnumerable<string> uris = await ewsClient.AppendMessagesAsync(
    EwsAppendMessage.Create()
        .AddMessage(message)
        .AddMessage(fetched)
        .SetFolder(folderUri)
        .SetCancellationToken(cancellationToken));

Copy item

string newItemUri = await ewsClient.CopyItemAsync(messageUri, destinationFolderUri, cancellationToken);

Delete item

await ewsClient.DeleteItemAsync(newItemUri, DeletionOptions.DeletePermanently, cancellationToken);

Delete folder

const bool deletePermanently = true;
await ewsClient.DeleteFolderAsync(folderUri, deletePermanently, cancellationToken);

Update item

await ewsClient.UpdateItemAsync(
    EwsUpdateItem.Create(mapiNote)
        .SetCancellationToken(cancellationToken));