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
 General SQL Server Forums
 New to SQL Server Programming
 xp_sendmail return values

Author  Topic 

ann06
Posting Yak Master

171 Posts

Posted - 2009-10-28 : 15:36:46
hi,

i want to run the sp of xp_sendmail but want to capture the result which is "mail sent" or the error returned if failed how to capture the result of the run sp although i don't know the output parameter that is defined in the sp

declare @result varchar(20)
set @result=exec.... could this work?

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2009-10-28 : 17:28:07
declare @result int
exec @result=xp_sendmail @subject='Test', @recipients='youremail@yourcompany.com'
print 'result = ' + IsNull(Cast(@result as varchar), 'No Value')
0 is success anything else is an error


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page
   

- Advertisement -