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
 SQL Server Development (2000)
 Stored Procedure and CDONTS

Author  Topic 

vegasvic
Starting Member

4 Posts

Posted - 2005-09-06 : 16:58:53
I have written a stored procedure that steps through a table in the db and populates 2 variables. The next step is to use another stored procedure that I have that send email using cdonts.

1st problem is I cant get the @CustomerId variable to concatenate into the paramaters to pass to the sp that send mail via cdonts.

2nd I tried hardcoding all the variables and it does not send the email at all. could someone review the code and give me some advice

thanks

Vegas Vic
Code Below:
CREATE procedure dbo.sp_emailECOMRPTS as

declare
@CustomerId as varchar(20),
@EmailAddy as varchar(255)


DECLARE C1 CURSOR READ_ONLY
FOR
SELECT CustomerID,Email
FROM Customers
WHERE HasReports = 1 and Email is not Null


OPEN C1

FETCH NEXT FROM C1 INTO @CustomerId,@EmailAddy
WHILE (@@fetch_status <> -1)
BEGIN IF (@@fetch_status <> -2)

BEGIN

exec sp_send_cdontsmail 'emgeserver@emgeast.com',@EmailAddy,',EMGE Inventory Revised with Vendor Sort','This is an automated Email. Please do not respond to it. Questions regarding this email should be directed toEMGCustomerService','','Z:\'@CustomerId'\Inv\101185tblInv9-6-2005.rpt'
END
FETCH NEXT FROM C1 INTO @CustomerId,@EmailAddy

END
CLOSE C1
DEALLOCATE C1
GO

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-09-06 : 17:32:54
CDONTS is deprecated, CDOSYS is it's replacement. There are several stored procs available that work with CDOSYS to send email. Do a search on the main site or via google and you should find 2 or 3 that will work for you.



-ec
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-09-07 : 00:28:30
http://www.orcsweb.com/articles/sendmailsql.aspx

http://www.sqlteam.com/filtertopics.asp?topicID=125

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -