ITokenProvider interface does not have any async friendly methods

We’re working on a multiplatform application and we have a common library that is reused across all our platforms. We need to be able to send email via Office365, so we’re using microsoft’s MSAL library to authenticate and get tokens

The problem we’re facing is that the Aspose library does not support the Async pattern in any of the email client options. There’s no option to call “await SendAsync(…)” for email. Specifically, our main issue at the moment is that the ITokenProvider interface does not have any async friendly methods. All samples online suggest to use AcquireToken() and then calling “.Result”. This is a bad practice and it is causing a deadlock when we try to send email.

We’ve worked around this by getting the access token before trying to send email, but we really need a way to send Email asynchronously so that we can use the latest .net features and take advantage of the async pattern and existing libraries that use that pattern to obtain tokens. As an added bonus this allows to send emails seamlessly without blocking the UI thread.

@logan1975

The SMTP, POP3 and IMAP clients support Async sending and you can please consider using them on your end, Please check the following methods as overloads for your convenience.

    SmtpClient smtpClient = new SmtpClient();
    smtpClient.SendAsync();
    ImapClient imap = new ImapClient();
    imap.AppendMessageAsync();
    Pop3Client pop3Client = new Pop3Client();
    pop3Client.SaveMessageAsync();

Thanks @mudassir.fayyaz, you are correct that there are async methods for the older protocols.
However I am referring to the newer OAuth2 protocols when using EWS and more specifically ITokenProvider.

This interface does not have any async methods - so as not to cause any deadlocks and block the UI

@logan1975

At present the async methods for EWS client are not available. A ticket with ID EMAILNET-40072 has been created as feature request to provide the requested support. This thread has been linked with the issue so that you may be notified once the issue will be addressed.