I have the following VB.Net console application subroutine, it reads emails from a table and attempts to send them, if it sends them successfully it will then update the same database as sent with the time.
This code was working fine, however I am now receiving the following error:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
I have tried running the SQL script separately in management studio and it works fine.
I have also tried verifying the server space and database size, both are fine.
Can anyone help with a solution?
Connection(True)
Using comSQL As New SqlCommand("SELECT * FROM Seq_Emails_ToSend", conSQL)
Using dr As SqlDataReader = comSQL.ExecuteReader
While dr.Read
Dim madTO As MailAddressCollection = ConvertStringtoMAD(dr("Email_TO").ToString)
Dim madCC As MailAddressCollection = ConvertStringtoMAD(dr("Email_CC").ToString)
Dim madBCC As MailAddressCollection = ConvertStringtoMAD(dr("Email_BCC").ToString)
Dim isHTML As Boolean = CBool(dr("Email_HTML").ToString)
Dim Priority As MailPriority = CInt(dr("Email_Priority").ToString)
Dim Subject As String = CStr(dr("Email_Subject").ToString)
Dim Body As String = CStr(dr("Email_Body").ToString)
Dim ID As Integer = CInt(dr("Email_ID").ToString)
Dim Status As String
If EmailFile(madTO, madCC, madBCC, "", isHTML, Priority, Subject, Body) Then
Status = "Sent"
Else
Status = "Failed"
End If
Using comSQL2 As New SqlCommand("UPDATE Seq_Emails SET [Status] = @Status, [Date_Sent] = @Date WHERE Email_ID = @ID", conSQL)
comSQL2.Parameters.Add("@ID", SqlDbType.Int).Value = ID
comSQL2.Parameters.Add("@Status", SqlDbType.NVarChar).Value = Status
comSQL2.Parameters.Add("@Date", SqlDbType.DateTime).Value = DateTime.Now
comSQL2.ExecuteNonQuery()
End Using
End While
End Using
End Using
Connection(False)