System.ObjectDisposedException when sending email using smtpclient
wilkovanderveen opened this issue · comments
I am getting a System.ObjectDisposedException
when i try to send an e-mail in a .NET core 6.0 project:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Mail.SmtpClient'.
at System.Net.Mail.SmtpClient.SendAsync(MailMessage message, Object userToken)
at FluentEmail.Smtp.SendMailEx.SendMailExImplAsync(SmtpClient client, MailMessage message, CancellationToken token)
I have tried to inject the smtpclient
transient, scoped and as a singleton but niether one of the options fixed this issue.
Never mind. Was my own mistake. I had to inject a custom smtpsender because of an issue with the current version and I had to use a singleton for the other services.