SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Sending Emails From SQL Server


Sending Emails From SQL Server

Author
Message
kickstand07
kickstand07
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
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?
Lowell
Lowell
One Orange Chip
One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)

Group: General Forum Members
Points: 28141 Visits: 39939
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!

kickstand07
kickstand07
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
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 Sad
Gail Wanabee
Gail Wanabee
Right there with Babe
Right there with Babe (742 reputation)Right there with Babe (742 reputation)Right there with Babe (742 reputation)Right there with Babe (742 reputation)Right there with Babe (742 reputation)Right there with Babe (742 reputation)Right there with Babe (742 reputation)Right there with Babe (742 reputation)

Group: General Forum Members
Points: 742 Visits: 1339
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>'


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search