i am not getting this store procedure , can you tell where is it "master..xp_sendmail"
i have send the mail when any insertion take place in particular table like "Emp"
According to Microsoft you should not use xp_sendmail anymore. Use this instead:
http://msdn.microsoft.com/en-us/library/ms175887(v=SQL.90).aspx
As for the process of sending the emails... I would decouple the insert and the sending of the emails. You could have a SQL Server job that polls for new entries in a table and sends the emails if needed. This job could be sheduled to run every 5 minutes.
Note from MS:
This feature will be removed in a
future version of Microsoft SQL
Server. Avoid using this feature in
new development work, and plan to
modify applications that currently use
this feature. To send mail from SQL
Server, use Database Mail.
EDIT: incorporated the usefull links from the comment of adolf garlic
http://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/
http://www.databasejournal.com/features/mssql/article.php/3626056/Database-Mail-in-SQL-Server-2005.htm
Related
I am looking to see if there is a viable solution to allow us to receive emails into SQL Server, process the content or linked attachments, and run a script on a database.
Currently we have a process where certain developers create basic scripts to modify one of a few of our production databases. They upload the scripts to our SVN and then email the DBA's with a link to the script. We then open it in SSMS and run, copy/pasting the output in response to the email. The process is primarily a separation of duties and to ensure that the DBA's are the only ones that can run the scripts.
But there are times when we may be unavailable and not able to be at a computer to run these in SSMS, but the business is waiting on these tables getting updated. I am trying to find a solution where we might be able to forward these emails if we see them, such as on our phones, to a receiving email on the SQL Server, and have a proc grab the script from SVN, maybe inserting the content of the script and mail into a database, and then running that script on the appropriate DB. My idea was having this on our MSX server and then it would be able to run on one of the servers via linked server or something. Then I want the output emailed back as confirmation.
I have looked around and most email related questions are about sending email. The only things I have found remotely related are about SQL Mail, which I understand is outdated and inefficient, and potentially CLR. Most of our environments are 2012+.
Am I on the right track with my thinking or is there something else I should be considering?
Thanks
Ok. I know SQL Mail is less secure and old, but what are the real advantages and differences between the two?
I read this article, which is pretty straight forward, but I was hoping to get someone to tell me why (if any) would you want to use SQL mail? Is it really out dated?
Thanks
Benefits of Database Mail over SQL Mail
Database Mail has the option of limiting file sizes to prevent sending large attachments
Database Mail can be configured with multiple SMTP accounts and with multiple profiles
No impact on the database performance, the mailing process is external
Having access to the mail history
Database mail :
Based on SMTP (Simple Mail Transfer Protocol).
Introduced in Sql 2005.
No need to install Outlook.
Depend on Service Broker service.
More secure than Sqlmail.
SQLMail
Based on MAPI (Messaging Application Programming Interface).
Used prior versions of Sql server 2005.
Require Outlook to be installed.
Leass secure than Database mail.
Link :
Database Mail
database-mail-vs-sql-mail
is it possible to send an email with SQL Server? I would like to be able to create a procedure for sending an email. It seems that I have to do some configuration according to this site but I don't have admin access on my machine. How can I achieve that ?
Thanks for your help !!
P.S : I am working on Windows
If you have limited privileges on the SQL Server why don't you write the query to obtain the users' names, email adresses and forgotten DVD titles and send the email from you application?
As long as you have access to an SMTP server you should be good to go.
Or you could always try the obvious:
USE YourDB;
GRANT CONTROL SERVER TO ME AS (JON_SKEET OR CHUCK_NORRIS);
GO
:-)
You could use a CLR Stored Procedure.
See this example for instance: Send Email from SQL Server Express Using a CLR Stored Procedure
Sending it via .NET would allow you to relay on a external SMTP and not having to configure Database Mail.
xp_sendmail is the command you want for older versions of SQL Server. Note that this is being removed from future versions, so for versions which support it use Database Mail.
EDIT Sorry - just read your full post. If you don't have the rights to enable mail sending, you'll need to speak to the admin who has. Server security is not designed to be "worked-around". Why does the mail have to be sent from SQL Server?
All of our correspondence is done via database mail in sql server. The data for document generation and the rules to trigger the generation are all on sql server. We now have to create a pdf file. I was planning on using pdfsharp/migradoc to do it, but then we'd have to create document and time its readiness with sql server data state and mail state. It'd be nice if the db could handle everything.
Has anyone created pdf files directly in sql server? And if so, how.
take a look here: Create data driven PDF on the fly by using SQL server reporting service (SSRS)
I've not used it, but there is SQL2PDF stored proc. It uses sp_OA% code.
Google search
Blog article and duplicated on SQL Server Central (needs login)
SQL isn't the best place to do this of course, but if you have to I'd use CLR if possible.
I would like to send an email from SQL Server 2005 Express using a trigger.
The solutions I have seen use the System Stored Procedures xp_sendmail
or sp_send_dbmail, but these are not available under SQL Express (will only work under full SQL Server).
Any suggestions would be appreciated.
Thanks
Sending an Email from a trigger sounds like a bad idea.
Why not poll the table and pick up modified records, then send an Email for each new/modified entry?
As Leather said, trying to send an email in a trigger is a bad idea.
While in my opinion upgrading to SQL Standard and using sp_send_dbmail is the best way to send email through a database, I believe you can accomplish what you want to do through the low-fi CDOSYS .
Described here: http://support.microsoft.com/kb/312839
I have not used CDOSYS since SQL 2000 so I don't know for sure that it will be your solution, but it does give you another avenue to learn about sending email pro grammatically.