The only system SP I have is master.dbo.xp_smtp_sendmail and I can't make it work (or I just don't know how). I cannot upgrade the DB at this time. I'm trying something like this:
@body_text=N'SELECT TOP 100 * FROM payhistory WHERE entered BETWEEN
DATEADD(wk,DATEDIFF(wk,7,GETDATE()),0)
AND DATEADD(wk,DATEDIFF(wk,7,GETDATE()),4) AND desk=020 ORDER BY entered
DESC
exec master.dbo.xp_smtp_sendmail
@server = 'server',
@from = 'administrator@mydomain.com',
@to = 'me@mydomain.com',
@subject = 'HTML Testing...',
@type = 'text/html',
@message = @body_text
I can do this easily in 2005 and up using "msdb.dbo.sp_send_dbmail" but I am stuck on 2000 due to the size of the DB for now.
Any help or suggestions would be greatly appreciated.
Thanks
Best Answer
It looks like you're missing an apostrophe from the end of the
@body_text
parameter. This fixes that problem:Also, You might consider using
xp_sendmail
from SQL Server 2000. The syntax is:Of course,
xp_sendmail
requires an Outlook profile be setup on the server, which might be prohibitive.