Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 impersonate user in xp_sendmail

Author  Topic 

b00gieman
Starting Member

14 Posts

Posted - 2008-02-27 : 05:01:46
Hi!

I want to use the xp_sendmail procedure.The problem is I don't have the permissions to do that.Instead , I should impersonate a generic user in order to send emails.From what I read , I think I should use the following command:

EXEC masted.dbo.xp_sendmail @recipients='recipient_mail',@subject='subject',@set_user='generic_username_I_should_impersonate'

Is that ok?

I tried this way,but I'm getting the following error:
EXECUTE permission denied on object 'xp_sendmail', database 'master', owner 'dbo'.



Could somebody help?

Thanks in advance!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-27 : 05:08:48
Try changing the user context by command 7 then executing

EXECUTE AS USER = 'generic_username_I_should_impersonate';


EXEC masted.dbo.xp_sendmail @recipients='recipient_mail'....
Go to Top of Page

b00gieman
Starting Member

14 Posts

Posted - 2008-02-27 : 06:14:06
I tried that,but I'm getting the error:
Incorrect syntax near the keyword 'as'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-27 : 12:28:02
refer this:-

http://msdn2.microsoft.com/en-us/library/ms188354.aspx
Go to Top of Page

b00gieman
Starting Member

14 Posts

Posted - 2008-03-10 : 05:08:42
I forgot to mention I'm using SQL Server 2000...It seems that I cannot use the xp_sendmail procedure , so I created my own stored procedure for sending emails.I don't have permissions for some components I'm using(I work in a database different than the 'master' database).I was told I can use a user that has those permissions , so I should impersonate that user.How can I do that?(SETUSER doesn't work...:( )
Go to Top of Page
   

- Advertisement -