Timeout in DatabaseMail

When sending a lot of emails in a bunch (100+) the databasemail errorlog shows errors like "Cannot send mails to mail server. (The operation has timed out.)".

A look in the (Application) Eventlog of the database server (SQL2008R2 10.50.2550) show me the following Error from DatabaseMail:

1) Exception Information
===================
Exception Type: Microsoft.SqlServer.Management.SqlIMail.Server.Common.BaseException
Message: There was an error on the connection.
Reason: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached., connection parameters: Server Name: [SERVER], Database Name: msdb
Data: System.Collections.ListDictionaryInternal
TargetSite: Void OpenConnection(Microsoft.SqlServer.Management.Common.SqlConnectionInfo)
HelpLink: NULL
Source: DatabaseMailEngine

StackTrace Information
===================
   at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.ConnectionManager.OpenConnection(SqlConnectionInfo ci)
   at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.OpenConnection(String dbServerName, String dbName, String userName, String password)
   at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.QueueItemProcesser.ProcessQueueItems(String dbName, String dbServerName, Int32 lifetimeMinimumSec, LogLevel loggingLevel)

2) Exception Information
===================
Exception Type: System.InvalidOperationException
Message: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.
Data: System.Collections.ListDictionaryInternal
TargetSite: System.Data.ProviderBase.DbConnectionInternal GetConnection(System.Data.Common.DbConnection)
HelpLink: NULL
Source: System.Data

StackTrace Information
===================
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.SqlClient.SqlConnection.Open()
   at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.ConnectionManager.OpenConnection(SqlConnectionInfo ci)

So my question is how to I configure DatabaseMail to use a larger pool size?

TIA

Adri Koopman

Nov

July 13th, 2015 12:24pm

Modify "Queue Length" in IIS 

MSDN Reference to set Queue Length property in IIS6 or IIS7 

Another reference here

Free Windows Admin Tool Kit Click here and download it now
July 13th, 2015 12:32pm

IIS? The server where it occurs is a database server, no IIS installed. The error comes from the "DatabaseMail" pogram (a part of the SQL Server installation) that handles the requests when a "sp_senddbmail" has been executed. In fact, it occurs when DatabaseMail wants to make a connection to SQLServer.

Regards,

Adri Koopman

July 15th, 2015 3:15am

First try sending test mail.

go to SSMS>>Management>>Database mail>>right click sent test mail.

check if it is working or not. If you have problem sending test mail contact your Exchange server team to configure your SMTP correctly to send mails. use the smtp server name correctly in your mail account setup.

Free Windows Admin Tool Kit Click here and download it now
July 16th, 2015 2:03am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics