Database mail does not work for one sql instance, returns error - Object reference not set to an instance of an object.

so here is my scenario, I have database mail working perfectly on a server on one instance of sql, it sends emails out as expected without any problem however when i try to test database mail on the same server on a different instance I get the "Object reference not set to an instance of an object." in the mail log.

I have hunted on the and not found a solution to the problem, I have tried deleting and recreating the profile and account, i have tried adding an entry to the host file and ensured that the relevant account has permissions to the "DatabaseMailUserRole". I am now stuck as to where i should look next. Any suggestions?

more ▼

asked Jan 03, 2012 at 05:33 AM in Default

avatar image

nick long
21 1 1 4

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

Sounds like a security setting issue. I'd validate that the services on both instances are running under the same security context. Then, validate the the logins you're using have the same security context in both instances.

more ▼

answered Jan 03, 2012 at 05:37 AM

avatar image

Grant Fritchey ♦♦
137k 20 43 81

Thanks Grant, I will look into it and let you know

Jan 03, 2012 at 05:59 AM nick long

So I found the issue, NT Authority did not have DBMailUserRole. Thanks again grant for pointing me in the right direction.

Jan 03, 2012 at 06:16 AM nick long

Not a problem. Glad to help. By the way, if you like the answer, please give it a thumb's up. If you think it was the right answer, please check the check box. It's how we keep score around here.

Jan 03, 2012 at 06:36 AM Grant Fritchey ♦♦
(comments are locked)
10|1200 characters needed characters left

hello guys can someone help me with this kind of error. i have a table "worker" that has field number and name i amm trying i have created a stored procedure from sql server 2008 itself. the stored procedure is like this

create procedure input @number int, @name varchar(10) as insert into worker values(@number,@name) and in vb 2008 i have put two textboxes and one button and the code is like the following: Public Class Form1 Dim conn As SqlConnection Dim cmd As SqlCommand

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
         conn = New SqlConnection("Data Source=bona-pc;Initial Catalog=workship;Integrated Security=True")
         cmd.Connection = conn
         cmd.CommandType = CommandType.StoredProcedure
         cmd = New SqlClient.SqlCommand("input", conn)
         cmd.Parameters.AddWithValue("@number", TextBox1.Text)
         cmd.Parameters.AddWithValue("@name", TextBox2.Text)
         TextBox1.Text = ""
         TextBox2.Text = ""
         MsgBox("Saved successfuly")
     Catch ex As Exception
         MessageBox.Show("Error while inserting record on table..." & ex.Message, "insert records")
     End Try
 after i have clicked the button the error comes saying:
 Error while inserting record on table... Object reference not set to an instance of an object.
 i have spent a whole day searching all over but if any one helps it would be so great for me. thx.
more ▼

answered Sep 26, 2012 at 03:08 PM

avatar image


I'd make more sense to post your own question/problem instead of posting it as an answer to something completely different.

Sep 26, 2012 at 04:23 PM DirkHondong
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Jan 03, 2012 at 05:33 AM

Seen: 3752 times

Last Updated: Sep 26, 2012 at 04:23 PM

Copyright 2016 Redgate Software. Privacy Policy