sp_smtp_sendmail  

Home
Up
What's New
DTS
SQL-DMO
SQL-NS
XP's
SQL Agent
Events
FAQ
Links
About...

 

sp_smtp_sendmail

version: 1.0.0.2

last updated: 18 September 2003

sp_smtp_sendmail is a wrapper stored procedure for xp_smtp_sendmail. This makes it easier to be used from environments like SQL Server DTS (SQL Task) which try to retrieve the parameter list of a procedure.

 

-- ***************************************************************************
-- Copyright (C) 1991-2003 SQLDEV.NET
--
-- file: sp_smtp_sendmail.sql
-- descr.: sp_smtp_sendmail
-- author: Gert E.R. Drapers (GertD@SQLDev.Net)
--
-- @@bof_revsion_marker
-- revision history
-- yyyy/mm/dd by      description
-- ========== ======= ========================================================
-- 2003/09/18 gertd   v1.0.0.2 @rc was not being set

-- 2003/07/29 gertd   v1.0.0.1 fixed @messagfile type, should be @messagefile

-- 2003/07/06 gertd   v1.0.0.0 created
-- @@eof_revsion_marker
-- ***************************************************************************
use master
go

if (not object_id('dbo.sp_smtp_sendmail') is null)
    drop proc dbo.sp_smtp_sendmail
go

create proc dbo.sp_smtp_sendmail
    @FROM NVARCHAR(4000) = NULL,
    @FROM_NAME NVARCHAR(4000) = NULL,
    @TO NVARCHAR(4000) = NULL,
    @replyto NVARCHAR(4000) = NULL,
    @CC NVARCHAR(4000) = NULL,
    @BCC NVARCHAR(4000) = NULL,
    @priority NVARCHAR(10) = N'NORMAL',
    @subject NVARCHAR(4000) = NULL,
    @message NVARCHAR(4000) = NULL,
    @messagefile NVARCHAR(4000) = NULL,
    @type NVARCHAR(100) = N'text/plain',
    @attachment NVARCHAR(4000) = NULL,
    @attachments NVARCHAR(4000) = NULL,
    @server NVARCHAR(4000) = N'smarthost',
    @codepage INT = 0,
    @timeout INT = 10000
as

declare @rc int

exec @rc = master.dbo.xp_smtp_sendmail
    @FROM = @FROM,
    @FROM_NAME = @FROM_NAME,
    @TO = @TO,
    @replyto = @replyto,
    @CC = @CC,
    @BCC = @BCC,
    @priority = @priority,
    @subject = @subject,
    @message = @message,
    @messagefile = @messagefile,
    @type = @type,
    @attachment = @attachment,
    @attachments= @attachments,
    @server = @server,
    @codepage = @codepage,
    @timeout = @timeout

if (@@error <> 0 or @rc <> 0)
    raiserror(N'Sending message using xp_smtp_sendmail failed', 16, 1)

return @rc
 

Download sp_smtp_sendmail.sql

***

Questions or problems regarding this web site should be directed to webmaster@sqldev.net.
Copyright © 1991-2003 SQLDev.Net. All rights reserved.
Last modified: 07/06/03.