我有以下 VB.Net 控制台应用程序子例程,它从表中读取电子邮件并尝试发送它们,如果成功发送它们,它将更新与发送时间相同的数据库。
此代码工作正常,但是我现在收到以下错误:
超时已过。在操作完成之前超时时间已过或服务器没有响应。
我曾尝试在管理工作室中单独运行 SQL 脚本,它工作正常。
我也试过验证服务器空间和数据库大小,两者都很好。
任何人都可以提供解决方案吗?
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)