Topic Contributors
creator avatar  
mreschke
Matthew Reschke
Site Developer
Created: Dec 23rd, 2009
Updated: Nov 27th, 2010
File
Download Selected (zip)
Download Selected (tar.gz)
Edit
Select All
Select None
View
Detail
Detail Preview
Icons
Preview
Show Hidden
Hide Hidden
Full Manager
Reset Defaults
icon
xpsmtp80-v1.1.0.8.zip
Open In New Tab
Open In New Window
List Archive Contents
Download File
Open
Download Folder (as .zip)
SMTP from MSSQL Procedure
Post # 167 permalink Topic #167 by mreschke on 2009-12-23 10:08:29 (viewed 1,077 times)
Table of Contents

Ability to send an email from a MSSQL Stored Procedure

http://www.sqldev.net/xp/xpsmtp.htm

Installation[-][- -][++]

  1. Download the attached .zip and extract
  2. Copy the xpsmtp80.dll to C:\Program Files\Microsoft SQL Server\MSSQL\Binn
  3. Run this procedure on the servers master database _
    SQL Code Snippet
    EXEC sp_addextendedproc 'xp_smtp_sendmail', 'xpsmtp80.dll'
     
  4. Use this syntax for a simple email _
    SQL Code Snippet
    DECLARE @rc INT
    EXEC @rc = master.dbo.xp_smtp_sendmail
        @FROM       = N'from@email.com',
        @FROM_NAME  = N'fromname',
        @replyto    = N'replyto@email.com',
        @TO         = N'to@email.com',
        @subject    = N'Your Subject Here',
        @TYPE       = N'text/html', 
        @message    = N'<b>Your</b> HTML body here',
        @timeout    = 10000,
        @server     = N'Your SMTP Server Here'
    SELECT RC = @rc