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)
 cdo_mail

Author  Topic 

sardinka
Posting Yak Master

142 Posts

Posted - 2004-07-21 : 10:29:14
I have the following sp where I am executing a cdo_mail.
I would like to put in a messagebody some results from exec sp. However it is not working. What am I doing incorrect?
declare @MessageBody varchar(2000)
set @MessageBody=exec sp
EXECUTE CDO_SendMail @From = 'from@com',
@To ='to@com',
@Cc = '',
@Bcc = '',
@Subject = 'Subject' ,
@MessageFormat = 0,
@Message = @MessageBody ,
@Priority = 2

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2004-07-21 : 20:18:09
I don't think you can assign the results of a stored procedure into a variable this way. You might want to do a search in these forums for sp_executesql and see how to pass a variable between two sprocs. However, even if you do get the results of a SELECT into the variable, I doubt that it will be formatted in any meaningful way to appear reasonably in the body of an email.

-----------------------------------------------------
Words of Wisdom from AjarnMark, owner of Infoneering
Go to Top of Page
   

- Advertisement -