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)
 Help with Multiple rows

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-06-29 : 11:41:03
Girish writes "Can I run a FOR Loop in the Stored Procedure to send emails from the SP.
I have independently written two SP one for getting the email address and subject. Other for sending the emails.

How do I combine the two. I am very new to the SP concept so please point me if an document already exist.

What i need is If First SP returns.

Sub EmailAdd (FORMAT)
One A@DOM.COM
Two B@DOM.COM
THR C@DOM.COM

Second Stored procedure (IS AN Aritcle I found on this site).
declare @rc int
exec @rc = master.dbo.xp_smtp_sendmail
@FROM = N'My@Domain.com',
@FROM_NAME = N'Joe Mailman',
@TO = N'My@Domain.com',
@CC = N'MyOtherFriend@HisDomain.com',

@BCC = N'My@Domain.com',
@priority = N'HIGH',
@subject = N'Hello SQL Server SMTP Mail',
@message = N'Goodbye MAPI, goodbye Outlook',
@type = N'text/plain',
@server = N'smtphub.com'
select RC = @rc
go

The @FROM and @Subject Should be the returns of the first SP and they should run in a loop (till records exist).

Thanks for the help
GIRISH"
   

- Advertisement -