Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Sending Emails From SQL Server Expand / Collapse
Author
Message
Posted Friday, December 7, 2012 2:21 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, January 3, 2013 7:23 AM
Points: 2, Visits: 6
Okay, so i have a query that i run several times a day. After running the query i then analyse the contents and send personalized reminders to the relevant contacts. Is there a way to send a batch of emails out based on criteria?
Post #1394248
Posted Friday, December 7, 2012 2:23 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:16 PM
Points: 14,460, Visits: 37,994
sure ; setting up database mail is very straightforward.
a query that uses an EXISTS clause can decide whether to send or not.
from there, you need to decide if it's one email with everyone CC'd or BCC'd, or an individual email for each person.


Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Post #1394251
Posted Friday, December 7, 2012 3:11 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, January 3, 2013 7:23 AM
Points: 2, Visits: 6
Wow! quick reply. This sounds promising, thanks. So i have several fields including: Ticket#, Assignee, Sched End Date, Sched Close date. I want to use the assignee user id as the destination, and then List the tickets details (ticket # etc) within the email, and all of these details would be different per entry. Does all of this still sound doable? I've only had a small amount of sql training, so pardon my stupidity
Post #1394263
Posted Wednesday, December 12, 2012 3:38 PM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, February 10, 2016 5:59 PM
Points: 279, Visits: 1,186
I think you can adapt this to work for you:

EXEC msdb.dbo.sp_send_dbmail 
@profile_name='<the name of the profile you created in Database Mail>',
@recipients='<10 digit cell phone number>@txt.att.net;emailName@emailServiceProvider.com',
@subject='<any printable characters>',
@body='<any printable characters>'

Post #1395907
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse