I am trying to send out 714 dynamic content emails but my email call fails around 400. Here is the event viewer error message:
FileName:
FileLineNumber: 0
FileColumnNumber: 0
Method: System.Net.OSSOCK.recv
StackTrace:
Message: System.Net.Mail.SmtpException: Failure sending mail. ---> System.Threading.ThreadAbortException: Thread was being aborted. at System.Net.UnsafeNclNativeMethods.OSSOCK.recv(IntPtr socketHandle, Byte* pinnedBuffer, Int32 len, SocketFlags socketFlags) at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode) at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.DelegatedStream.Read(Byte[] buffer, Int32 offset, Int32 count) at System.Net.BufferedReadStream.Read(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine) at System.Net.Mail.EHelloCommand.Send(SmtpConnection conn, String domain) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at DotNetNuke.Services.Mail.Mail.SendMailInternal(MailMessage mailMessage, String subject, String body, MailPriority priority, MailFormat bodyFormat, Encoding bodyEncoding, IEnumerable`1 attachments, String smtpServer, String smtpAuthentication, String smtpUsername, String smtpPassword, Boolean smtpEnableSSL)
And here is the call to send the emails I am using:
Protected Sub btnEmailAllDnnUsers_Click(sender As Object, e As EventArgs) Handles btnEmailAllDnnUsers.Click
Dim smtpServer As String = ""
Dim subject As String = String.Empty
Dim body As String = String.Empty
Dim CommunityDB As CommunityDataContext
CommunityDB = New CommunityDataContext()
Dim Successlist As List(Of CommunityTables.FUDS_AccountSuccess)
If Request.IsLocal Then
smtpServer = "localhost"
End If
subject = "TEST USER ACCOUNT"
Successlist = CommunityDB.FUDS_AccountSuccesses().ToList
For Each User In Successlist
body = String.Format("FUDS Training portal.{1}Your new UserName is: {0}{1}Your new password is: {2}", User.UserName, Environment.NewLine, User.Password)
Try
DotNetNuke.Services.Mail.Mail.SendMail("DoNotReply@FUDSTraining.usace.army.mil", User.Email, "", subject, body, "", "", smtpServer, "", "", "")
Dim emailSuccess As CommunityTables.FUDS_EmailSuccess = New FUDS_EmailSuccess
emailSuccess.UserName = User.UserName
emailSuccess.UserID = User.UserID
emailSuccess.Password = User.Password
CommunityDB.FUDS_EmailSuccesses.InsertOnSubmit(emailSuccess)
CommunityDB.SubmitChanges()
Catch ex As Exception
Dim emailFailure As CommunityTables.FUDS_EmailFailure = New FUDS_EmailFailure
emailFailure.UserName = User.UserName
emailFailure.UserID = User.UserID
emailFailure.Password = User.Password
CommunityDB.FUDS_EmailFailures.InsertOnSubmit(emailFailure)
CommunityDB.SubmitChanges()
End Try
Next
End Sub
Can you please help me understand why this is happening and how can I fix it? I cannot use scheduler to do this because I pull email address from the database and add a dynamic body to the email. Any help would be much appreciated.
Thanks!