﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / T-SQL (SS2K5)  / Email attachment script ? / 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>Sun, 19 May 2013 19:52:35 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Email attachment script ?</title><link>http://www.sqlservercentral.com/Forums/Topic1394774-338-1.aspx</link><description>Great, thank you much!!!!</description><pubDate>Mon, 10 Dec 2012 15:13:43 GMT</pubDate><dc:creator>jude-32296</dc:creator></item><item><title>RE: Email attachment script ?</title><link>http://www.sqlservercentral.com/Forums/Topic1394774-338-1.aspx</link><description>it's just example WHERE statement for the data; your query which gathers the "right" emails  would be very specific to your business logic, and especially the WHERE statement which decides whether someone gets an email or not;i just wanted to show, as an example, you don't send to every email in a table, there should be logic.same thing for [b]distinct email[/b], if someone is in the table more than once, you don't want to look unprofessional by sending them multiple emails.finally, you can see i was using a udf to make sure an email was valid...no sense trying to send to an empty string, or an email that doesn't have the @ symbol in it.</description><pubDate>Mon, 10 Dec 2012 15:01:27 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>RE: Email attachment script ?</title><link>http://www.sqlservercentral.com/Forums/Topic1394774-338-1.aspx</link><description>Now I feel really dumb, but what is "CampaignID" ?</description><pubDate>Mon, 10 Dec 2012 14:49:32 GMT</pubDate><dc:creator>jude-32296</dc:creator></item><item><title>RE: Email attachment script ?</title><link>http://www.sqlservercentral.com/Forums/Topic1394774-338-1.aspx</link><description>a rough example of multiple recipients from a query, unique emails, same attachment:[code]declare  @isql varchar(2000),  @email varchar(64)    declare c1 cursor for select distinct email FROM DatabaseName.dbo.SomeTable WHERE CampaignID = 42 and dbo.IsValidEmail(email) = 1  open c1  fetch next from c1 into @email  While @@fetch_status &amp;lt;&amp;gt; -1    begindeclare @body1 varchar(4000)set @body1 = 'Latest documentation For You. ' + CONVERT( VARCHAR( 20 ), GETDATE(), 113 ) + ' 'EXEC msdb.dbo.sp_send_dbmail @recipients=@email,    @subject = 'Latest documentation ',    @body = @body1,    @body_format = 'HTML',    @file_attachments = 'c:\ServerAttachments\ERP.pdf'        fetch next from c1 into @email    end  close c1  deallocate c1[/code]</description><pubDate>Mon, 10 Dec 2012 14:00:56 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>RE: Email attachment script ?</title><link>http://www.sqlservercentral.com/Forums/Topic1394774-338-1.aspx</link><description>I want to send 100 different emails (Notifying customers of a change) &amp; yes, the word document will be on the Sql server.thx!</description><pubDate>Mon, 10 Dec 2012 13:56:26 GMT</pubDate><dc:creator>jude-32296</dc:creator></item><item><title>RE: Email attachment script ?</title><link>http://www.sqlservercentral.com/Forums/Topic1394774-338-1.aspx</link><description>so you want to send 100 individualized emails, each with the same (or different?) attachment?(hint: cursor)or do you want to send a [b]single [/b]email, with 100 To:/CC:/BCC:/ and the same attachment?and finally, does the attachment exist on the SQL server?</description><pubDate>Mon, 10 Dec 2012 13:54:58 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>Email attachment script ?</title><link>http://www.sqlservercentral.com/Forums/Topic1394774-338-1.aspx</link><description>I have a sql table that contains 100 email addresses &amp; a word document that needs to be sent to these recipients.  Does anyone have a script to read through a table &amp; send an email with a document attachment I can use ?thx!</description><pubDate>Mon, 10 Dec 2012 13:51:30 GMT</pubDate><dc:creator>jude-32296</dc:creator></item></channel></rss>