SQL Server 2005 數據庫郵件運行一年多突然失敗,錯誤日誌顯示:
Exception Type: Microsoft.SqlServer.Management.SqlIMail.Server.Common.BaseException
Message: 無法從隊列中檢索項。
StackTrace: ... CommandFactory.CreateSendMailCommand ...
郵件服務器配置正常,本地測試可發送,僅生產環境異常。
SQL Server 2005 早期版本存在已知 Bug,導致 Database Mail 引擎在特定條件下(如隊列積壓、連接池耗盡)無法正確處理郵件發送命令,拋出 BaseException。
https://www.microsoft.com/en-us/download/details.aspx?id=26727(需選擇對應架構 x86/x64/IA64)。msdb 郵件配置。-- 升級後執行測試
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'YourProfile',
@recipients = 'test@example.com',
@subject = 'SP4 Upgrade Test',
@body = 'If you see this, SP4 fixed the issue.';
sysmail_event_log 定期清理舊日誌防止表膨脹。