Solved

Problem with using Databasemail with SQL Server 2005

Posted on 2012-04-07
15
856 Views
Last Modified: 2012-04-21
Hello,
I want to use databasemail to send automatic reports.
So I run Databasemail Configuration Wizar, after few minutes everything was complete.
Then I send test mail from SQL Server 2005, nothing happens.

From computer where is installed SQL Server 2005 i can telnet to smtp without any problems. Everything seems to be ok.

On developing server where is installed SQL Server 2008R2 i configure exactly same parameters like on SQL Server 2005. On develop server databasemail works fine.


In the end i lookup for errors in EventViewer and i found 2 errors:

FIRST

Event Type:      Error
Event Source:      DatabaseMail
Event Category:      None
Event ID:      0
Date:            2012-04-06
Time:            14:18:03
User:            N/A
Computer:      HADRON
Description:


1) Exception Information
===================
Exception Type: System.TypeInitializationException
TypeName: System.Data.SqlClient.SqlConnection
Message: The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.
Data: System.Collections.ListDictionaryInternal
TargetSite: Void .ctor(System.String)
HelpLink: NULL
Source: System.Data

StackTrace Information
===================
   at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
   at Microsoft.SqlServer.Management.Common.SqlConnectionInfo.CreateConnectionObject()
   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.TypeInitializationException
TypeName: System.Data.SqlClient.SqlConnectionFactory
Message: The type initializer for 'System.Data.SqlClient.SqlConnectionFactory' threw an exception.
Data: System.Collections.ListDictionaryInternal
TargetSite: Void .cctor()
HelpLink: NULL
Source: System.Data

StackTrace Information
===================
   at System.Data.SqlClient.SqlConnection..cctor()

3) Exception Information
===================
Exception Type: System.TypeInitializationException
TypeName: System.Data.SqlClient.SqlPerformanceCounters
Message: The type initializer for 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception.
Data: System.Collections.ListDictionaryInternal
TargetSite: Void .ctor()
HelpLink: NULL
Source: System.Data

StackTrace Information
===================
   at System.Data.SqlClient.SqlConnectionFactory..ctor()
   at System.Data.SqlClient.SqlConnectionFactory..cctor()

4) Exception Information
===================
Exception Type: System.Configuration.ConfigurationErrorsException
Message: Configuration system failed to initialize
BareMessage: Configuration system failed to initialize
Filename: NULL
Line: 0
Errors: System.Configuration.ConfigurationException[]
Data: System.Collections.ListDictionaryInternal
TargetSite: Void EnsureInit(System.String)
HelpLink: NULL
Source: System.Configuration

StackTrace Information
===================
   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
   at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
   at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
   at System.Diagnostics.DiagnosticsConfiguration.Initialize()
   at System.Diagnostics.Switch.InitializeConfigSettings()
   at System.Diagnostics.Switch.InitializeWithStatus()
   at System.Diagnostics.Switch.get_SwitchSetting()
   at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String categoryName, String categoryHelp)
   at System.Data.SqlClient.SqlPerformanceCounters..ctor()
   at System.Data.SqlClient.SqlPerformanceCounters..cctor()

5) Exception Information
===================
Exception Type: System.Configuration.ConfigurationErrorsException
Message: Unrecognized configuration section system.serviceModel. (C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Config\machine.config line 134)
BareMessage: Unrecognized configuration section system.serviceModel.
Filename: C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Config\machine.config
Line: 134
Errors: System.Configuration.ConfigurationException[]
Data: System.Collections.ListDictionaryInternal
TargetSite: Void ThrowIfErrors(Boolean)
HelpLink: NULL
Source: System.Configuration

StackTrace Information
===================
   at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
   at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.


SECOND

Event Type:      Error
Event Source:      .NET Runtime 2.0 Error Reporting
Event Category:      None
Event ID:      5000
Date:            2012-04-06
Time:            14:18:04
User:            N/A
Computer:      HADRON
Description:
EventType clr20r3, P1 databasemail90.exe, P2 9.0.242.0, P3 4d0276ad, P4 system, P5 2.0.0.0, P6 4ea7901b, P7 5a2, P8 7, P9 system.typeinitialization, P10 NIL.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 63 00 6c 00 72 00 32 00   c.l.r.2.
0008: 30 00 72 00 33 00 2c 00   0.r.3.,.
0010: 20 00 64 00 61 00 74 00    .d.a.t.
0018: 61 00 62 00 61 00 73 00   a.b.a.s.
0020: 65 00 6d 00 61 00 69 00   e.m.a.i.
0028: 6c 00 39 00 30 00 2e 00   l.9.0...
0030: 65 00 78 00 65 00 2c 00   e.x.e.,.
0038: 20 00 39 00 2e 00 30 00    .9...0.
0040: 2e 00 32 00 34 00 32 00   ..2.4.2.
0048: 2e 00 30 00 2c 00 20 00   ..0.,. .
0050: 34 00 64 00 30 00 32 00   4.d.0.2.
0058: 37 00 36 00 61 00 64 00   7.6.a.d.
0060: 2c 00 20 00 73 00 79 00   ,. .s.y.
0068: 73 00 74 00 65 00 6d 00   s.t.e.m.
0070: 2c 00 20 00 32 00 2e 00   ,. .2...
0078: 30 00 2e 00 30 00 2e 00   0...0...
0080: 30 00 2c 00 20 00 34 00   0.,. .4.
0088: 65 00 61 00 37 00 39 00   e.a.7.9.
0090: 30 00 31 00 62 00 2c 00   0.1.b.,.
0098: 20 00 35 00 61 00 32 00    .5.a.2.
00a0: 2c 00 20 00 37 00 2c 00   ,. .7.,.
00a8: 20 00 73 00 79 00 73 00    .s.y.s.
00b0: 74 00 65 00 6d 00 2e 00   t.e.m...
00b8: 74 00 79 00 70 00 65 00   t.y.p.e.
00c0: 69 00 6e 00 69 00 74 00   i.n.i.t.
00c8: 69 00 61 00 6c 00 69 00   i.a.l.i.
00d0: 7a 00 61 00 74 00 69 00   z.a.t.i.
00d8: 6f 00 6e 00 20 00 4e 00   o.n. .N.
00e0: 49 00 4c 00 0d 00 0a 00   I.L.....

When i run manually databasemail90.exe, then in the EventViewer came out same errors.

Configuration:
Windows Server 2003 x64 with updates
SQL Server 2005 x64 with updates


How handle this problem ?

Thanks in advance.
0
Comment
Question by:jposp
  • 8
  • 7
15 Comments
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37818577
can you kill the databasemail executable on the server and then try again.
0
 

Author Comment

by:jposp
ID: 37818586
@Anuroopsundd - yesterday i restarted server, so i think this is equal to re-run databasemail executable;

EDIT:
i checkout windows process and there was no databasemail process
0
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37818587
Yes, restart do the stuff.
by any chance can you reinstall the latest Service pack for sql ?
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:jposp
ID: 37818591
0
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37818594
That's right..
0
 

Author Comment

by:jposp
ID: 37818782
@Anuroopsundd - i try to reinstall SP4, but i can't update database services beacause it is up-to-date
0
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37818806
0
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37818810
To use this wizard you must be a member of the sysadmin fixed server role. To send Database Mail you must be a member of the DatabaseMailUserRole database role in the msdb database.

Note:  
Enabling SQL Server Service Broker in any database requires a database lock. If Service Broker was deactivated in msdb, to enable Database Mail, first stop SQL Server Agent so Service Broker can obtain the necessary lock.

http://msdn.microsoft.com/en-us/library/ms175951(v=sql.90).aspx
0
 

Author Comment

by:jposp
ID: 37818828
I configure database mail like in sqlserverclub.com, i don't think is problem with config.

I troubleshoot with:
http://msdn.microsoft.com/en-us/library/ms187540(v=sql.90).aspx
and seems to be ok, except the fact, that mail are still in queue.
0
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37818835
so you are seeing the mail in outlook queue.?
0
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37818836
were you able to test account setting in outlook?
0
 

Author Comment

by:jposp
ID: 37836361
I'm back :)

So i didn't install Outlook on server. But I test that account setting in Outlook and in development SQL Server 2008R2 and it works fine.
0
 

Author Comment

by:jposp
ID: 37850638
In SQL Server Agent Log i found this:


[260] Unable to start mail session (reason: System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnectionFactory' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.Confi)



SQL Surface Area Configuration - exception when chosen Features
And this is my machine.config serviceModel section:


<system.serviceModel>
    <extensions>
      <behaviorExtensions>
        <add name="persistenceProvider" type="System.ServiceModel.Configuration.PersistenceProviderElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add name="workflowRuntime" type="System.ServiceModel.Configuration.WorkflowRuntimeElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add name="enableWebScript" type="System.ServiceModel.Configuration.WebScriptEnablingElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add name="webHttp" type="System.ServiceModel.Configuration.WebHttpElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </behaviorExtensions>
      <bindingElementExtensions>
        <add name="webMessageEncoding" type="System.ServiceModel.Configuration.WebMessageEncodingElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add name="context" type="System.ServiceModel.Configuration.ContextBindingElementExtensionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </bindingElementExtensions>
      <bindingExtensions>
        <add name="wsHttpContextBinding" type="System.ServiceModel.Configuration.WSHttpContextBindingCollectionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add name="netTcpContextBinding" type="System.ServiceModel.Configuration.NetTcpContextBindingCollectionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add name="webHttpBinding" type="System.ServiceModel.Configuration.WebHttpBindingCollectionElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add name="basicHttpContextBinding" type="System.ServiceModel.Configuration.BasicHttpContextBindingCollectionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </bindingExtensions>
    </extensions>
    <client>
      <metadata>
        <policyImporters>
          <extension type="System.ServiceModel.Channels.ContextBindingElementImporter, system.workflowservices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
        </policyImporters>
        <wsdlImporters>
          <extension type="System.ServiceModel.Channels.ContextBindingElementImporter, system.workflowservices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
        </wsdlImporters>
      </metadata>
    </client>
  </system.serviceModel>
0
 

Accepted Solution

by:
jposp earned 0 total points
ID: 37850906
I'm resolved problem.
I've used http://blogs.msdn.com/b/joy/archive/2008/07/22/how-to-use-microsoft-net-framework-cleanup-utility.aspx and then reinstall .NET Framework 2.0, now everything works :)
0
 

Author Closing Comment

by:jposp
ID: 37875016
There was a problem with machine.config, probably it was corrupted, after reinstall .net framework works ok
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question