Я пытаюсь отправить электронное письмо 250 моим пользователям. Это мой код:
using(var emailClient = new SmtpClient())
{
emailClient.Connect(Configuration.Server, Configuration.Port, Configuration.UseSSL);
emailClient.AuthenticationMechanisms.Remove("XOAUTH2");
emailClient.Authenticate(Configuration.UserName, Configuration.Password);
try
{
foreach(var item in EmailContents)
{
var message = new MimeMessage();
message.To.AddRange(item.Receiver.Select(x => new MailboxAddress(x)));
message.From.AddRange(item.Sender.Select(x => new MailboxAddress(x)));
message.Subject = item.Subject;
message.Body = new TextPart(TextFormat.Html)
{
Text = item.Content
};
emailClient.Send(message);
}
}
catch(Exception e)
{
logger.LogError(e,ResilientLogger.ClassLibrary.Globals.LoggingGlobals.Error + "-" + e.Message);
}
emailClient.Disconnect(true);
}
Однако по какой-то причине я продолжаю получать эту ошибку:
MailKit.Net.Smtp.SmtpCommandException: Too many recipients
at MailKit.Net.Smtp.SmtpClient.OnRecipientNotAccepted(MimeMessage message, MailboxAddress mailbox, SmtpResponse response)
at MailKit.Net.Smtp.SmtpClient.ProcessRcptToResponse(MimeMessage message, MailboxAddress mailbox, SmtpResponse response)
at MailKit.Net.Smtp.SmtpClient.RcptToAsync(FormatOptions options, MimeMessage message, MailboxAddress mailbox, Boolean doAsync, CancellationToken cancellationToken)
at MailKit.Net.Smtp.SmtpClient.SendAsync(FormatOptions options, MimeMessage message, MailboxAddress sender, IList`1 recipients, Boolean doAsync, CancellationToken cancellationToken, ITransferProgress progress)
at MailKit.Net.Smtp.SmtpClient.SendAsync(FormatOptions options, MimeMessage message, MailboxAddress sender, IList`1 recipients, Boolean doAsync, CancellationToken cancellationToken, ITransferProgress progress)
at MailKit.Net.Smtp.SmtpClient.Send(FormatOptions options, MimeMessage message, CancellationToken cancellationToken, ITransferProgress progress)
at ManagementStudio.Connect.Email.Email.BulkSend(EmailConfigurationViewModel Configuration, List`1 EmailContents)
Это ошибка IIS или что-то, что я могу исправить в своем коде? Я использую IIS8