﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Kunal Das / Article Discussions / Article Discussions by Author  / Using Xp_sendmail With the Recipients Generated From a Query / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 18:02:00 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>This is a guess, but is Outlook installed on the server?  And if so, is it configured correctly?Dave</description><pubDate>Mon, 02 Feb 2009 14:31:15 GMT</pubDate><dc:creator>David Jackson</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>Hi David;I am using the same to send Mail from SQL Server 2000But i am getting this error message:   xp_sendmail: failed with mail error 0x80040111Could you please help me out in this case , i need the solutionThanks !!</description><pubDate>Mon, 02 Feb 2009 08:52:56 GMT</pubDate><dc:creator>igsri</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>In 2005, xp_sendmail should be avoided.  It's been replaced by sp_sendDBMail, which tends to operate much better (it's SMTP-based, so doesn't required an outlook client to be installed and configured; it also doesn't wait for the e-mail to complete, so your SQL server doesn't have to become dependent on where Exchange Server is up or down....)  It's not on by default, so you need to use the Surface Area Config tool to enable it.</description><pubDate>Mon, 06 Oct 2008 09:00:27 GMT</pubDate><dc:creator>Matt Miller (#4)</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>This is written for, and tested on SQL 2000 I'm afraid.  I do not have 2005 so I can't help you there.  I assume the xp_sendmail parameters have changed.  Or another thought, out of the box in SQL 2005 is xp_sendmail disabled? If so, have you enabled it?HTHDave J</description><pubDate>Mon, 06 Oct 2008 03:51:58 GMT</pubDate><dc:creator>David Jackson</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>Hi, Thanks for the such a wonderful script.I run your script, its working fine, but  mail haven't send to any one.I think There could be extra setting needs to do for the xp_sendmail.Would you Please email, what are the Pre-requities to send a  mail from Sql server 2005.my mail id is mayurs@winsoftech.com.I appreciate your time and help.Thanking you.regards,mayur</description><pubDate>Fri, 03 Oct 2008 05:23:33 GMT</pubDate><dc:creator>mayurs</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>Hi david, Thanks for the good script.But after executing script, I got an error message.it is " xp_sendmail: Procedure expects parameter @user, which was not supplied. "help me to overcome from it.Thanking you.mayur.</description><pubDate>Fri, 03 Oct 2008 04:39:49 GMT</pubDate><dc:creator>mayurs</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>&lt;P&gt;My code is below,  my issue is when this executes,  lets say the query brings back 2 email address,  instead of sending one to each name it send 2 to each name.  How/where can I fix this??&lt;/P&gt;&lt;P&gt;CREATE   PROCEDURE usp_email_ccb&lt;/P&gt;&lt;P&gt;AS&lt;/P&gt;&lt;P&gt;DECLARE @TITLE VARCHAR(500)DECLARE @DESCRIPTION VARCHAR(500)DECLARE @REQUIREMENTS VARCHAR(500)Declare @MyRecipients nvarchar (255)Declare @NEWMessage nvarchar (255)Declare @NEWSubject nvarchar (255)DECLARE @RECORD_NUM NCHAR(2)Declare MyCursor Cursor For &lt;/P&gt;&lt;P&gt;Select LOGINID From USERS  Where TASK='CCB'&lt;/P&gt;&lt;P&gt;Open MyCursor&lt;/P&gt;&lt;P&gt;Fetch Next From MyCursor Into @MyRecipients &lt;/P&gt;&lt;P&gt;While @@Fetch_Status = 0&lt;/P&gt;&lt;P&gt;BEGIN&lt;/P&gt;&lt;P&gt;Print @MyRecipients &lt;/P&gt;&lt;P&gt;Fetch Next From MyCursor Into @MyRecipients&lt;/P&gt;&lt;P&gt;select  @record_num=[id], @title=[title],  @description=[description], @REQUIREMENTS=[REQUIREMENTS]  from display a,(select max(id) mxid from display) b where a.id=b.mxid&lt;/P&gt;&lt;P&gt;SET @NEWSUBJECT='YOU HAVE AN IT REQUEST TO APPROVE!!!  THIS IS A TEST EMAIL FOR THE WAP TOOL, JUST DISREGARD!!!'SET @NEWMESSAGE='TITLE:  &lt;A href="mailto:'+@TITLE"&gt;'+@TITLE&lt;/A&gt; + " " + +CHAR(13)+ +CHAR(13)+ 'DESCRIPTION:  &lt;A href="mailto:'+@DESCRIPTION"&gt;'+@DESCRIPTION&lt;/A&gt; +  " " + +CHAR(13)++CHAR(13)+ 'REQUIREMENTS:  &lt;A href="mailto:'+@REQUIREMENTS"&gt;'+@REQUIREMENTS&lt;/A&gt; +  " "++CHAR(13)++CHAR(13)+ + 'Click on this link to view your request.  &lt;A href="http://localhost/WAP/db/ba2btpeb2.asp?a=GETRECORD&amp;amp;ID='+@RECORD_NUM"&gt;http://localhost/WAP/db/ba2btpeb2.asp?a=GETRECORD&amp;amp;ID='+@RECORD_NUM&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Exec Master.dbo.xp_sendmail  @MyRecipients,  @SUBJECT &lt;A href="mailto:=@NEWSUBJECT"&gt;=@NEWSUBJECT&lt;/A&gt;, @MESSAGE=@NEWMESSAGE&lt;/P&gt;&lt;P&gt;End &lt;/P&gt;&lt;P&gt;Close MyCursor&lt;/P&gt;&lt;P&gt;Deallocate MyCursorGO&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Wed, 26 Jul 2006 09:21:00 GMT</pubDate><dc:creator>Michael Weiss</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>&lt;P&gt;How would you add the subject to the message instead of getting the default of "SQL SERVER MESSAGE"?  I've tried adding the @subject = 'Test Subject' but get an error "Must pass parameter number 2 and subsequent parameters as &lt;A href="mailto:'@name"&gt;'@name&lt;/A&gt; = value'. After the form &lt;A href="mailto:'@name"&gt;'@name&lt;/A&gt; = value' has been used, all subsequent parameters must be passed in the form &lt;A href="mailto:'@name"&gt;'@name&lt;/A&gt; = value'."  I then tried to add DECLARE @MYSUBJECT nvarchar (255) and then SET @MYSUBJECT = 'Test Subject' and then &lt;/P&gt;&lt;P&gt;Exec Master.dbo.xp_sendmail  @mysubject ,@MyRecipients, @MyMessage  END END .  That gives an ODBC error 170 (42000)&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description><pubDate>Tue, 04 Apr 2006 07:40:00 GMT</pubDate><dc:creator>ew</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>&lt;P&gt;Here's my stab at it.&amp;lt;&lt;CODE&gt;&lt;SPAN style="FONT: 10pt Courier New"&gt;&lt;FONT color=blue&gt;/* Created by free online sql formatter: http://www.wangz.net/gsqlparser/sqlpp/sqlformat.htm */&lt;/FONT&gt;&lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;/*This sets up a quick test table*/&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;IF&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;object_id&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;'DJmailDetails_T'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN style="COLOR: black"&gt;0&lt;/SPAN&gt;  &lt;SPAN style="COLOR: blue"&gt;DROP&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;TABLE&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;djmaildetails_t&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;CREATE&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;TABLE&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;djmaildetails_t&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;  &lt;SPAN style="COLOR: maroon"&gt;id&lt;/SPAN&gt;           &lt;SPAN style="COLOR: black"&gt;INT&lt;/SPAN&gt;  &lt;SPAN style="COLOR: blue"&gt;NOT&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;NULL&lt;/SPAN&gt;  &lt;SPAN style="COLOR: blue"&gt;IDENTITY&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt; &lt;SPAN style="COLOR: black"&gt;1&lt;/SPAN&gt;  &lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR: black"&gt;1&lt;/SPAN&gt;  &lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;  &lt;SPAN style="COLOR: maroon"&gt;firstname&lt;/SPAN&gt;    &lt;SPAN style="COLOR: black"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;30&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;  &lt;SPAN style="COLOR: blue"&gt;NOT&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;NULL&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;  &lt;SPAN style="COLOR: maroon"&gt;lastname&lt;/SPAN&gt;     &lt;SPAN style="COLOR: black"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;30&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;  &lt;SPAN style="COLOR: blue"&gt;NOT&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;NULL&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;  &lt;SPAN style="COLOR: maroon"&gt;emailaddress&lt;/SPAN&gt; &lt;SPAN style="COLOR: black"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;100&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;  &lt;SPAN style="COLOR: blue"&gt;NOT&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;NULL&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;  &lt;SPAN style="COLOR: maroon"&gt;sendmail&lt;/SPAN&gt;     &lt;SPAN style="COLOR: black"&gt;BIT&lt;/SPAN&gt;  &lt;SPAN style="COLOR: blue"&gt;NOT&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;NULL&lt;/SPAN&gt;  &lt;SPAN style="COLOR: blue"&gt;DEFAULT&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;INSERT&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;INTO&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;djmaildetails_t&lt;/SPAN&gt;           &lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;firstname&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: maroon"&gt;lastname&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: maroon"&gt;emailaddress&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: maroon"&gt;sendmail&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;VALUES&lt;/SPAN&gt;     &lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;'dave'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: red"&gt;'jackson'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: red"&gt;'me@nonworkingExample.co.uk'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: black"&gt;1&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;INSERT&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;INTO&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;djmaildetails_t&lt;/SPAN&gt;           &lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;firstname&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: maroon"&gt;lastname&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: maroon"&gt;emailaddress&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: maroon"&gt;sendmail&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;VALUES&lt;/SPAN&gt;     &lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;'fred'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: red"&gt;'bloggs'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: red"&gt;'you@nonworkingExample.co.uk'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: black"&gt;1&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;INSERT&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;INTO&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;djmaildetails_t&lt;/SPAN&gt;           &lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;firstname&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: maroon"&gt;lastname&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: maroon"&gt;emailaddress&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: maroon"&gt;sendmail&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;VALUES&lt;/SPAN&gt;     &lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;'joe'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: red"&gt;'smith'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: red"&gt;'him@nonworkingExample.co.uk'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: black"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;INSERT&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;INTO&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;djmaildetails_t&lt;/SPAN&gt;           &lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;firstname&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: maroon"&gt;lastname&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: maroon"&gt;emailaddress&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: maroon"&gt;sendmail&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;VALUES&lt;/SPAN&gt;     &lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;'mike'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: red"&gt;'jones'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: red"&gt;'her@nonworkingExample.co.uk'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;            &lt;SPAN style="COLOR: black"&gt;1&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;/*This selects from above table*/&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;DECLARE&lt;/SPAN&gt;  &lt;SPAN style="COLOR: #8000ff"&gt;@recipients&lt;/SPAN&gt; &lt;SPAN style="COLOR: black"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;4000&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8000ff"&gt;@recipients&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: fuchsia"&gt;Coalesce&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #8000ff"&gt;@recipients&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;';'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;''&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;emailaddress&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;FROM&lt;/SPAN&gt;   &lt;SPAN style="COLOR: maroon"&gt;djmaildetails_t&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;WHERE&lt;/SPAN&gt;  &lt;SPAN style="COLOR: maroon"&gt;sendmail&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: black"&gt;1&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;PRINT&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8000ff"&gt;@recipients&lt;/SPAN&gt; &lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;-- show what we got&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;PRINT&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;''&lt;/SPAN&gt; &lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;-- a blank line&lt;/SPAN&gt;&lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;/***************************************************************************************************/&lt;/SPAN&gt;&lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;/*The next two variables are normally set in theerror handling of each 'bit' of DML in your SP/Script*/&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;DECLARE&lt;/SPAN&gt;  &lt;SPAN style="COLOR: #8000ff"&gt;@Error_status&lt;/SPAN&gt; &lt;SPAN style="COLOR: black"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;DECLARE&lt;/SPAN&gt;  &lt;SPAN style="COLOR: #8000ff"&gt;@Error_message&lt;/SPAN&gt; &lt;SPAN style="COLOR: black"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;128&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;SET&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8000ff"&gt;@Error_status&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;-&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;1&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;SET&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8000ff"&gt;@Error_message&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;'failure updating something!'&lt;/SPAN&gt; &lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;--something apposite&lt;/SPAN&gt;                     &lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;/*This should be in the error handler of the script or SP*/&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;ERRORHANDLER:&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;DECLARE&lt;/SPAN&gt;  &lt;SPAN style="COLOR: #8000ff"&gt;@sql&lt;/SPAN&gt; &lt;SPAN style="COLOR: black"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;8000&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;DECLARE&lt;/SPAN&gt;  &lt;SPAN style="COLOR: #8000ff"&gt;@mailMessage&lt;/SPAN&gt; &lt;SPAN style="COLOR: black"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;128&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;DECLARE&lt;/SPAN&gt;  &lt;SPAN style="COLOR: #8000ff"&gt;@mailSubject&lt;/SPAN&gt; &lt;SPAN style="COLOR: black"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: black"&gt;128&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;DECLARE&lt;/SPAN&gt;  &lt;SPAN style="COLOR: #8000ff"&gt;@Procedure_Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: black"&gt;SYSNAME&lt;/SPAN&gt; &lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;-- Holds the name of the currently executing procedure&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;SET&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8000ff"&gt;@Procedure_Name&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: fuchsia"&gt;Object_name&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: fuchsia"&gt;@@PROCID&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;-- Set the procedure name in the variable&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;SPAN style="FONT: 10pt Courier New"&gt;&lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;/*the next two lines would not be called above normally, so needs to be commented out here.declare @recipients varchar(4000)Select @recipients = COALESCE(@recipients+';' , '') + emailAddress from DJmailDetails_T where sendMail = 1*/&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;SPAN style="FONT: 10pt Courier New"&gt;&lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;/*This sends the message*/&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;SET&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8000ff"&gt;@mailMessage&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;'Table update failure'&lt;/SPAN&gt; &lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;--something apposite&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;SET&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8000ff"&gt;@mailSubject&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;'Error in '&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;+&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: fuchsia"&gt;Isnull&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #8000ff"&gt;@Procedure_Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;'Ad-hoc Query'&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;SET&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8000ff"&gt;@sql&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;'exec master.dbo.xp_sendmail '''&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8000ff"&gt;@recipients&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;''',@message = '''&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8000ff"&gt;@mailMessage&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;''',@query = ''select '''''&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8000ff"&gt;@error_message&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;''''' as ErrorMessage,'&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;+&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT: bold; COLOR: fuchsia"&gt;Isnull&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: fuchsia"&gt;&lt;A href="mailto:CAST@Error_status"&gt;CAST&lt;/SPAN&gt;&lt;SPAN style="COLOR: #8000ff"&gt;@Error_status&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;AS&lt;/SPAN&gt; &lt;SPAN style="COLOR: black"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;' as ErrorNumber'',@subject = '''&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: #8000ff"&gt;@mailSubject&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;+&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;''',@dbuse = ''master'',@attach_results = false,@no_output = true,@width = 8000'&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;PRINT&lt;/SPAN&gt; &lt;SPAN style="COLOR: silver"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR: #8000ff"&gt;@sql&lt;/SPAN&gt;&lt;SPAN style="COLOR: silver"&gt;)&lt;/SPAN&gt;  &lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;--change this from print to an exec to 'really' do it.&lt;/SPAN&gt;&lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;--exec (@sql) --or uncomment this line&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;SPAN style="FONT: 10pt Courier New"&gt;&lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;/*Script to drop the table when finished testing&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN style="FONT: 10pt Courier New"&gt;&lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;if object_id('DJmailDetails_T') &amp;gt; 0&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;SPAN style="FONT: 10pt Courier New"&gt;&lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;drop table DJmailDetails_T&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN style="FONT: 10pt Courier New"&gt;&lt;SPAN style="COLOR: green; FONT-STYLE: italic"&gt;*/&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;I liked this so much I posted it on my site at &lt;A href="http://glossopian.co.uk/pmwiki.php?n=Main.XPSendMailWithRecipientsFromAQuery"&gt;http://glossopian.co.uk&lt;/A&gt;Dave J&lt;/P&gt;</description><pubDate>Fri, 18 Feb 2005 10:12:00 GMT</pubDate><dc:creator>David Jackson</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>We have looked at sending a newsletter type HTML mail and are looking at the sp_makewebtask and sp_runwebtask stored procedures.In testing we have used these procedures to generate e-mails as files then have use xp_cmdshell to copy them to the Pickup directory of the SMTP server. </description><pubDate>Thu, 12 Jun 2003 02:09:00 GMT</pubDate><dc:creator>David.Poole</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>Is it possible to use xp_sendmail to send html-format email? There is a message type (@type =) parameter, but where does one find info on custom message types? </description><pubDate>Wed, 11 Jun 2003 11:38:00 GMT</pubDate><dc:creator>jvg</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>&lt;BLOCKQUOTE id=quote&gt;&lt;font size=1 face="Verdana, Arial, Helvetica" id=quote&gt;quote:&lt;hr height=1 noshade id=quote&gt;What about when the email name you are retrieving from a table is no longer valid?  Any ideas on error processing?Can't quite get this part to work properly, or it works okay until the 1st illegal name is encountered then "rolls back".  Then retries x number of times (something you define) and then sends the emails out again until that first illegal address is encountered.  Wish xp_sendmail had error processing and was documented better.To make a long story short, if you try to process email addresses in a table within a proc, it can't roll back xp_sendmail operations and if you have set retry option up then you get duplicate emails sent to some humorless people! &lt;hr height=1 noshade id=quote&gt;&lt;/BLOCKQUOTE id=quote&gt;&lt;/font id=quote&gt;&lt;font face="Verdana, Arial, Helvetica" size=2 id=quote&gt; </description><pubDate>Thu, 13 Feb 2003 09:41:00 GMT</pubDate><dc:creator>aliozer</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>Check out my problem:http://www.sqlservercentral.com/forum/link.asp?TOPIC_ID=9937Is there anyway to get the cursor to continue once xp_sendmail has encountered an invalid email account? </description><pubDate>Wed, 12 Feb 2003 08:51:00 GMT</pubDate><dc:creator>mylesjj</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>[quote]I am a little confused the only way I got a mail session to work was to have a nt profile and outlook profile set up on the server then I was able to start the mail session.How did you get a second outlook profile to work with a different name?Well that's my question actually...Sql BOL says I can "start" sqlmail with the "@user" argument which basically allows me to choose a different outlook profile.  Query Analyzer says succesfully started and stopped with teh new profile, but, it just does'nt happen.RegardsUday  </description><pubDate>Mon, 13 May 2002 22:52:00 GMT</pubDate><dc:creator>uday</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>&lt;BLOCKQUOTE id=quote&gt;&lt;font size=1 face="Verdana, Arial, Helvetica" id=quote&gt;quote:&lt;hr height=1 noshade id=quote&gt;hmm... is there any way to send attachments with xp_sendmail?  im working on an application for a call center that needs to generate info on a persons queue, dump them to an excel spreadsheet, and then send out the spreadsheets.Yes, if you use @attach_results = 'TRUE', @width = 350Also, just a thought, when creating the Excel spreadsheet, it's easier for users to open if you create a comma delimited file and use the .csv suffix.Casey &lt;hr height=1 noshade id=quote&gt;&lt;/BLOCKQUOTE id=quote&gt;&lt;/font id=quote&gt;&lt;font face="Verdana, Arial, Helvetica" size=2 id=quote&gt; </description><pubDate>Mon, 13 May 2002 09:52:00 GMT</pubDate><dc:creator>casey</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>&lt;BLOCKQUOTE id=quote&gt;&lt;font size=1 face="Verdana, Arial, Helvetica" id=quote&gt;quote:&lt;hr height=1 noshade id=quote&gt;hmm... is there any way to send attachments with xp_sendmail?  im working on an application for a call center that needs to generate info on a persons queue, dump them to an excel spreadsheet, and then send out the spreadsheets. &lt;hr height=1 noshade id=quote&gt;&lt;/BLOCKQUOTE id=quote&gt;&lt;/font id=quote&gt;&lt;font face="Verdana, Arial, Helvetica" size=2 id=quote&gt; </description><pubDate>Mon, 13 May 2002 09:50:00 GMT</pubDate><dc:creator>casey</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>I am a little confused the only way I got a mail session to work was to have a nt profile and outlook profile set up on the server then I was able to start the mail session.How did you get a second outlook profile to work with a different name? </description><pubDate>Mon, 13 May 2002 08:14:00 GMT</pubDate><dc:creator>pisoft1</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>Guys!First of all thankx to Kunal for sharing this with us.  Now, my problem:- I'm using SQL Mail to send out Emails to Customers re: outstanding Invoices.  I also use SQL Mail on the same box to send out emails to our Sales Reps with summaries of outstanding invoices.  Now, I've set up multiple outlook profiles on the server.  I tried using xp_startmail @user = 'CreditControlDept'xp_sendmail .... (to customers)xp_stopmail @user = 'CreditControlDept'xp_startmail @user = 'InvoiceTracker'xp_sendmail...(to internal sales reps)xp_stopmail @user = 'InvoiceTracker'DOES NOT WORK!!! the profile does'nt switch at all.  SQL Mail sends out all the emails using the profile that it started with.  How can I use xp_startmail and xp_stopmail to switch between different user profiles.RegardsUday </description><pubDate>Thu, 09 May 2002 18:13:00 GMT</pubDate><dc:creator>uday</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>hmm... is there any way to send attachments with xp_sendmail?  im working on an application for a call center that needs to generate info on a persons queue, dump them to an excel spreadsheet, and then send out the spreadsheets. </description><pubDate>Thu, 09 May 2002 12:38:00 GMT</pubDate><dc:creator>inkntation</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>Yes, you have to have SQL Mail started prior to using xp_sendmail. You can start it through the GUI by using Enterprise Manager or you can use the T-SQL form of xp_startmail. Hope this helps. See Books Online for more specifics of xp_sendmail and xp_startmail.Jason Delaune </description><pubDate>Mon, 06 May 2002 22:10:00 GMT</pubDate><dc:creator>Jason Delaune</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>Do you have to have SQL Mail set up to use xp_sendmail?</description><pubDate>Mon, 06 May 2002 20:15:00 GMT</pubDate><dc:creator>Connie Miner</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>Good thought provoking article, got some new ideas on e-mail and cursors.&lt;img src=icon_smile_approve.gif border=0 align=middle&gt; </description><pubDate>Tue, 23 Apr 2002 07:00:00 GMT</pubDate><dc:creator>vijay_kumar</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>I used the same code that's in the article for a recent project, and it works great. However, I noticed in the code that the first recipient will not receive the email. 1. This is because after you fetch their email address, you then check the FETCH_STATUS to make sure it's valid. 2. You then print the email address and fetch a new one. 3. Then the email is sent. It seems that you would want to send the email before fetching the next record. Otherwise, someone will be left out.Jason </description><pubDate>Mon, 11 Mar 2002 08:43:00 GMT</pubDate><dc:creator>Jason Delaune</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>What about when the email name you are retrieving from a table is no longer valid?  Any ideas on error processing?Can't quite get this part to work properly, or it works okay until the 1st illegal name is encountered then "rolls back".  Then retries x number of times (something you define) and then sends the emails out again until that first illegal address is encountered.  Wish xp_sendmail had error processing and was documented better.To make a long story short, if you try to process email addresses in a table within a proc, it can't roll back xp_sendmail operations and if you have set retry option up then you get duplicate emails sent to some humorless people! </description><pubDate>Mon, 11 Feb 2002 16:14:00 GMT</pubDate><dc:creator>jamyer</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>An excellent tipRex</description><pubDate>Tue, 29 Jan 2002 08:15:00 GMT</pubDate><dc:creator>rbenemer</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>Very good information.  I have done this before but never quite so eloquently.&lt;img src=icon_smile_big.gif border=0 align=middle&gt;===================="Awful tired now, Boss.  Dog tired."http://www.dwacon.com</description><pubDate>Tue, 24 Jul 2001 14:10:00 GMT</pubDate><dc:creator>dwacon</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>Thx for that code David, I might actually change mine ;)...I wanted to avoid cursors, but it was the first thing I could think of..bad habits die hard...As to Bo's question, I read an article, I can't quite remember where, but someone had an article posted on how to use Outlook Express and Third Party mailers with xp_Sendmail..I'll see if I can find it.Real Programmers don't comment their code. If it was hard to write it should be hard to understand.</description><pubDate>Mon, 16 Jul 2001 09:44:00 GMT</pubDate><dc:creator>Blasphemy</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>Here is the same thing avoiding CURSORs.Use Test GODeclare @MyRecipients nvarchar (255)Declare @MyMessage nvarchar (255)Set @MyRecipients=''Set @MyMessage = ‘Your timesheet is overdue, please send it ASAP.'WHILE @MyRecipients IS NOT NULL    BEGIN         SELECT @MyRecipients = MIN ( email_address )         FROM Test_Table         WHERE enail_Address &amp;gt; @MyRecipients AND Status = 0         IF @MyRecipients IS NOT NULL             BEGIN                 Print @MyRecipients                  Exec Master.dbo.xp_sendmail @MyRecipients, @MyMessage             END    END </description><pubDate>Mon, 16 Jul 2001 04:51:00 GMT</pubDate><dc:creator>David.Poole</dc:creator></item><item><title>RE: Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>I had been looking for an article like this.  Thank you.  I still have the problem that sql2000 doesn't seem to like to send through Outlook express for instance.  Is there a workaround for this or another very minimal other mail client that might work or is there a way to send straight to smtp server?  Could there be a followup article about connecting the entire thing together? Thanks, Bo </description><pubDate>Mon, 16 Jul 2001 04:48:00 GMT</pubDate><dc:creator>bograham</dc:creator></item><item><title>Using Xp_sendmail With the Recipients Generated From a Query</title><link>http://www.sqlservercentral.com/Forums/Topic559-56-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF=http://www.sqlservercentral.com/columnists/kdas/xp_sendmail.asp&gt;http://www.sqlservercentral.com/columnists/kdas/xp_sendmail.asp&lt;/A&gt;</description><pubDate>Tue, 10 Jul 2001 00:00:00 GMT</pubDate><dc:creator>Blasphemy</dc:creator></item></channel></rss>