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)
 xp_sendmail...@subject

Author  Topic 

brendalisalowe
Constraint Violating Yak Guru

269 Posts

Posted - 2004-11-10 : 14:19:47
I want to be able to pull data from a table and put that into the subject line of an email. Can anyone tell me why this won't work?

declare @counter int
declare @length int
declare @subjname char
set @length = (select count(CaseNumber) From tblEmail)
set @subjname = (select CaseNumber from tblEmail)
set @counter = 0
while @counter < @length
begin
exec master..xp_sendmail
@recipients='collections@capitaltracer.com',
@subject= @subjname,
@message = 'Send out a letter!'
set @counter = @counter + 1
end

and when I do this, it only puts a 3 in the subject line:

declare @counter int
declare @length int
declare @subjname varchar
set @length = (select count(CaseNumber) From tblEmail)
set @subjname = '321-654987'
set @counter = 0
while @counter < @length
begin
exec master..xp_sendmail
@recipients='collections@capitaltracer.com',
@subject= @subjname,
@message = 'Send out a letter!'
set @counter = @counter + 1
end

Thanks!

Brenda

If it weren't for you guys, where would I be?

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2004-11-11 : 02:20:28
Brenda
Will it send mail at all??
Or are you having trouble creating a "mass mail sproc".
Do an article search on here for email for different examples
[url]http://www.sqlteam.com/searchresults.asp?SearchTerms=email&SUBMITs1=Search[/url]

With regards to your other question you have not specified a data length, so because it isnt specified SQL uses the default (1)

DECLARE @subjname varchar(100)
SET @subjname = '321-654987'
SELECT @subjname

Andy
Go to Top of Page
   

- Advertisement -