Solved

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

Posted on 2011-03-03
5
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Backup & Restore 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.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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…

752 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