Hi folks!
I am trying to add select criteria to my SQL mail. Eventually I would like to add an attachment but I will save that discussion for another day, unless someone feels compelled to help me with that. For purposes of this question - What I am trying to do is simply add a select statement in to an already existing mail query. Here's the mail query:
declare @Body varchar(4000)
Select @Body = 'test'
exec sp_send_cdosysmail 'someone@microsoft.com','someone2@microsoft.com','Test of CDOSYS',@Body
With the use of a custom stored procedure (for SMTP mail) this statement works fine. I'd like to add a query from my database but am not sure how to embed it into this existing query.
For example:
declare @Body varchar(4000)
Select @Body = ???
exec sp_send_cdosysmail 'someone@microsoft.com','someone2@microsoft.com','Test of CDOSYS',@Body
The intent would be to have the results show in the body of the mail.
Here is an example of the select statement I currently run independent of this function:
Select Precip1Production.Date_Time,
Precip1Production.Chem1,
Precip1Production.Chem2,
Precip1Production.Chem3,
Precip1Production.Chem4,
Precip1Production.Chem5,
Precip1Production.Chem6,
Precip1Production.Alum,
Precip1Production.Phenolic,
Precip1Production.Fiber1,
Precip1Production.Fiber2,
Precip1Production.Latex1,
Precip1Production.Latex2,
Precip1Production.CarbonBlack,
Precip1Production.Darvan,
Precip1Production.Caustic,
Precip1Production.Coagulant,
Precip1Production.Hot_Water,
Precip1Production.Wash_Water,
Precip1Production.ManualAdd1,
Precip1Production.ManualAdd2,
Precip1Production.ManualAdd3,
Precip1Production.HardwoodPulp,
Precip1Production.Polymin,
Precip1Production.SodAlum,
Precip1Production.AMX,
Precip1Production.Kymene,
Precip1Production.Batches,
Precip1Production.Recipe
FROM
Precip1Production
WHERE
(Precip1Production.Recipe = '57343A') AND (Precip1Production.Date_Time BETWEEN '10/6/2002 10:17:35 AM' AND '10/9/2002 10:17:35 AM')
ORDER BY
Precip1Production.Date_Time ASC
Can anyone show me how to embed this?
Thank a lot in advance!
John
I am trying to add select criteria to my SQL mail. Eventually I would like to add an attachment but I will save that discussion for another day, unless someone feels compelled to help me with that. For purposes of this question - What I am trying to do is simply add a select statement in to an already existing mail query. Here's the mail query:
declare @Body varchar(4000)
Select @Body = 'test'
exec sp_send_cdosysmail 'someone@microsoft.com','someone2@microsoft.com','Test of CDOSYS',@Body
With the use of a custom stored procedure (for SMTP mail) this statement works fine. I'd like to add a query from my database but am not sure how to embed it into this existing query.
For example:
declare @Body varchar(4000)
Select @Body = ???
exec sp_send_cdosysmail 'someone@microsoft.com','someone2@microsoft.com','Test of CDOSYS',@Body
The intent would be to have the results show in the body of the mail.
Here is an example of the select statement I currently run independent of this function:
Select Precip1Production.Date_Time,
Precip1Production.Chem1,
Precip1Production.Chem2,
Precip1Production.Chem3,
Precip1Production.Chem4,
Precip1Production.Chem5,
Precip1Production.Chem6,
Precip1Production.Alum,
Precip1Production.Phenolic,
Precip1Production.Fiber1,
Precip1Production.Fiber2,
Precip1Production.Latex1,
Precip1Production.Latex2,
Precip1Production.CarbonBlack,
Precip1Production.Darvan,
Precip1Production.Caustic,
Precip1Production.Coagulant,
Precip1Production.Hot_Water,
Precip1Production.Wash_Water,
Precip1Production.ManualAdd1,
Precip1Production.ManualAdd2,
Precip1Production.ManualAdd3,
Precip1Production.HardwoodPulp,
Precip1Production.Polymin,
Precip1Production.SodAlum,
Precip1Production.AMX,
Precip1Production.Kymene,
Precip1Production.Batches,
Precip1Production.Recipe
FROM
Precip1Production
WHERE
(Precip1Production.Recipe = '57343A') AND (Precip1Production.Date_Time BETWEEN '10/6/2002 10:17:35 AM' AND '10/9/2002 10:17:35 AM')
ORDER BY
Precip1Production.Date_Time ASC
Can anyone show me how to embed this?
Thank a lot in advance!
John