Solved

Sending email using SQL Server Agent, stored procedure and Com object

Posted on 2011-03-03
5
269 Views
Last Modified: 2012-05-11
I need to have a SQL stored procedure run periodically and send emails to users using smtp. I don't want to use the built in SQL Mail.

Please provide suggestions for commercial software
0
Comment
Question by:Rich-Alaska
5 Comments
 
LVL 3

Accepted Solution

by:
IamTheMorsa earned 167 total points
ID: 35029644
Sticking with SQL mail is a good route, but I did find these, but not exp with them.  http://sql-email.software.informer.com/
0
 

Author Comment

by:Rich-Alaska
ID: 35029727
I have IT SQL Admins complain about SQL Mail because a user needs access to MSDB in order to execute the stored procedure to send the mail.
0
 
LVL 13

Assisted Solution

by:dwkor
dwkor earned 166 total points
ID: 35029749
I'd use SQL Mail if possible. If it does not work for you for some reason, don't use the com object. This is very bad way to do that and can introduce ton of the issues - memory management, stability, etc.

Consider to either create external process that scan database and send or, at least, use CLR stored procedure that dumps results as the files and process that picks those files and process them. In the worst case, use CLR sp instead of COM but ask yourself what is the license cost for 1 SQL Server CPU vs. 1 application server cpu.

I doubt there are a lot of commercial software available because there are not so many customers who would be interested in such workflow
0
 
LVL 13

Expert Comment

by:dwkor
ID: 35029770
> I have IT SQL Admins complain about SQL Mail because a user needs access to MSDB in order to execute the stored procedure to send the mail.

Create "proxy" stored procedure that calls sql mail in your db and impersonate
0
 
LVL 32

Assisted Solution

by:bhess1
bhess1 earned 167 total points
ID: 35030520
Tell the SQL Admins that they just need to think outside the box.  Basically, if your admins want to control this, then do something like the following:

1)  Create an email staging table containing the necessary data for sending an email.  Don't limit yourself in the options you allow to be added - if you leave off something because it's not used now, it will be asked for next month.

2)  Have the SQL Admins create a job that looks in this table every so often - minute, hour, five minutes, whatever is an acceptable delay for sending the mail

3)  Have the job send the emails

If the admins want to do a bit more work, they can set up triggering actions on insert into the table that could send items as it is entered.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now