locked
Trouble with SQL 2005 Database Mail RRS feed

  • Question

  • Good day,

    I am trying to utilize Database Mail to alert when jobs fail/complete.  I have configured Database Mail, have set up a profile, ensured it is default, and tested sending mail using it.  It appears to be set up correctly however when a job does fail, the SQL Agent log shows that a mail session cannot be started as the configuration could not be read.

    The exact error is:

    Message

    [260] Unable to start mail session (reason: Microsoft.SqlServer.Management.SqlIMail.Server.Common.BaseException: Mail configuration information could not be read from the database. ---> System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'.

       at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.GetAccount(Int32 accountID)

       --- End of inner exception stack trace ---

       at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.GetAccount(Int32 accountID)

    )

    I've tried restarting DB Mail, deleting and recreating profiles and accounts, as well as restarting the SQL Agent.  All of which have not allowed DB Mail to create a session.

    We're running the agent as a user other than NT AUTHORITY\SYSTEM.  This user is a member of sysadmin.  When I've tested setting the user back to NT AUTHORITY\SYSTEM DB Mail starts up fine.

    I'm assuming this is some kind of permissions issue, and I've tried searching this forum, so please excuse me if this has been asked before, but I do not know where else to look.

    Thanks!

    Wednesday, December 22, 2010 5:05 PM

All replies

  • When you test the DBMail - do you test using the Mail configuration tool or do you try using a script from an open window?   

    Wednesday, December 22, 2010 5:44 PM
  • Hi Matt

    Just checking if you have ensure that the mail profile is enabled. Do this by going to the SQL Server Management Studio, then

    • Right click on the SQL Server Agent
    • Go to Alert System
    • Make sure that the Enable mail profile is checked and the mail system and mail profile settings are correct

    Thank you

    Lucas

    Wednesday, December 22, 2010 9:04 PM
  • Hi Matt.w,

     

    As per this KB 2008286, I would like to suggest you apply the latest Service Package for SQL Server 2005. The SP4 for SQL Server 2005 has been released recently, please go the below link to download:

    http://www.microsoft.com/downloads/en/details.aspx?FamilyID=b953e84f-9307-405e-bceb-47bd345baece&displaylang=en

     

    If there are any progress, please feel free let me know.

     

    Thanks,
    Weilin Qiao

    </form>
    Friday, December 24, 2010 10:20 AM
  • I installed SP4 for SQL Server 2005 on Windows Server 2008 and am now just recieving this error. Wondering if there are specific dll files or some other updates that were included in the SP3 CU4 update that are not present in SP4 for this fix? Dbmail was working fine until SP4 was installed.
    Monday, June 13, 2011 4:04 PM
  • We are getting the same error in SQL Agent Log, even after installing SP4 for SQL Server 2005:

    Message
    [260] Unable to start mail session (reason: Microsoft.SqlServer.Management.SqlIMail.Server.Common.BaseException: Mail configuration information could not be read from the database. ---> System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'.
       at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.GetAccount(Int32 accountID)
       --- End of inner exception stack trace ---
       at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.GetAccount(Int32 accountID)
    )


    Tatyana S.
    Monday, September 19, 2011 3:02 PM
  • I would head for the suggestion from Luca, seems that there is no valid profile entered in there.

    -jens


    Jens K. Suessmeyer http://blogs.msdn.com/Jenss
    Monday, September 19, 2011 10:42 PM