Solved

Problem with using Databasemail with SQL Server 2005

Posted on 2012-04-07
15
849 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
 

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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Agent Timeout 5 48
Need help with a query 6 67
Table create permissions on SQL Server 2005 9 41
How can i get data when i use where clause with group by? 3 23
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

861 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now