|
-
Jan 10th, 2002, 02:01 PM
#1
Thread Starter
Frenzied Member
Stored Procedure - What can it do?
Can a stored procedure in SS2K send an email?
I understand how to make a stored procedure (aka SP), but how would i get the SP to send an email? All the examples i've seen around here don't do anything like that.
If it can't, how could i get the SP to return the recordset object that the SQL statement creates to VB? That SQL statement will contain all the records/info i want/need in order to create the email.
~Peter

-
Jan 10th, 2002, 02:12 PM
#2
Check out extended system stored procedure xp_sendmail
Just bear in mind that you have to have an email account setup by lan admin, or whoever is responsible for the mail server.
-
Jan 10th, 2002, 02:17 PM
#3
Thread Starter
Frenzied Member
You're gonna have to tell me where that is located in SS2K. I can't find it anywhere.
~Peter

-
Jan 10th, 2002, 03:36 PM
#4
Open SQL Server Books Online and in the index type in xp_sendmail.....select transact-SQL version.
-
Jan 11th, 2002, 11:19 AM
#5
Thread Starter
Frenzied Member
Thanks. I managed to get that installed and i was able to locate that example. That looks like exactly what i want it to do. Thanks.
I will try it out as soon as i can get my job to run. I made a simple Stored Procedure, and then made a job that run the SP, however the Job will not run. It's very odd. I have it set to run in 2 minutes, but after 4 minutes have elapsed, the Job still has a Last Run Status of "Unknown". Weird. Very weird.
~Peter

-
Jan 11th, 2002, 02:56 PM
#6
Thread Starter
Frenzied Member
While i am trying to get my Job to run (why it won't run, i have no idea), i decided to start building the email portion.
I created a Stored Procedure like so:
VB Code:
CREATE PROCEDURE [dbo].[sp_SendEmail] AS
EXEC xp_sendmail 'robertk', 'The master database is full.'
GO
When i try running that SP from within Query Analyzer, i get this error:
Server: Msg 2812, Level 16, State 62, Line 3
Could not find stored procedure 'xp_sendmail'.
Something tells me i don't have the same things you have.
~Peter

-
Jun 15th, 2004, 07:52 AM
#7
New Member
U can send mails in 2 ways in SQL SERVER.
1. Write 1 stored proc in which u can create reference to
vbs CDONTS object using sp_OAcreate sp.
Once u create the object, we need to set property and finally need to use send method of this object.
Properttoes can be set using sp_OAsetProperty ...
2. Use xp_sendmail to send mails directly.
When we run this extended stored procedure, SQL SERVER SERVICES should be run in Domain account instead of Local account.
Raheem
-
Jun 15th, 2004, 08:38 AM
#8
Use master..xp_sendmail instead of just xp_sendmail.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|