Public Class Form1
Private _token As Threading.CancellationToken
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim semaphore As New Threading.SemaphoreSlim(5, 5)
For i As Integer = 0 To 20
Task.Factory.StartNew(Sub()
Try
semaphore.Wait(Me._token)
If Me._token.IsCancellationRequested Then Exit Sub
Using client As New SmtpClient
With client
.Host = "smtp.office365.com"
.Username = "bla"
.Password = "bla"
.Port = 587
.SecurityOptions = SecurityOptions.SSLExplicit
End With
Dim mail As Aspose.Email.MailMessage = Aspose.Email.MailMessage.Load(My.Application.Info.DirectoryPath + "\mail.msg")
client.Send(mail)
mail.Dispose()
mail = Nothing
End Using
Catch ex As Exception
Console.WriteLine(ex.ToString)
End Try
End Sub, Me._token).ContinueWith(Function(x) semaphore.Release())
Next
End Sub
End Class
We have tested your sample project attached here with this thread, but were not able to reproduce the exception at our end. We just modified the server and account credentials information and tested the same at our end with Gmail SMTP which didn’t raise any exception. Could you please make sure that you are using the latest version of the API at your end?
Public Class Form1
Private _token As Threading.CancellationToken
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim semaphore As New Threading.SemaphoreSlim(5, 5)
For i As Integer = 0 To 20
Task.Factory.StartNew(Sub()
Try
semaphore.Wait(Me._token)
If Me._token.IsCancellationRequested Then Exit Sub
Using client As New SmtpClient
With client
.Host = "smtp.office365.com"
.Username = "bla"
.Password = "bla"
.Port = 587
.SecurityOptions = SecurityOptions.SSLExplicit
End With
End Using
Catch ex As Exception
Console.WriteLine(ex.ToString)
End Try
End Sub, Me._token).ContinueWith(Function(x) semaphore.Release())
Next
End Sub
End Class
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim semaphore As New Threading.SemaphoreSlim(5, 5)
For i As Integer = 0 To 20
Task.Factory.StartNew(Sub()
Try
semaphore.Wait(Me._token)
If Me._token.IsCancellationRequested Then Exit Sub
Using client As New SmtpClient
End Using
Catch ex As Exception
Console.WriteLine(ex.ToString)
End Try
End Sub, Me._token).ContinueWith(Function(x) semaphore.Release())
Despite all our efforts and testing with different .NET frameworks, we are still not able to reproduce the issue at our end. Could you please try it on another PC and let us know your feedback? Meanwhile, an investigation ticket with id: EMAILNET-38773 has been logged in our issue tracking system for further investigation by our Product team. We’ll update you here once there is some information available in this regard.
Since the issue has already been logged, our Product team will further look into it for any such possible chance of exception. We’ll update you here once there is some information available in this regard.
The issues you have found earlier (filed as EMAILNET-38773) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by kashif.iqbal
We have just released Aspose.Email for .NET 17.8 where this issue has been fixed. Please try it at your end and let us know if you have any further inquiry in this regard.