Home Forums SQL Server 2005 Administering How to generate email from database( MS SQL SERVER 2000 or 2005) RE: How to generate email from database( MS SQL SERVER 2000 or 2005)

  • Check master DB for the XP_SMTP_SENDMAIL extended stored proc or download xpsmtp80.dll and add it as an extended stored proc

    Create the proc below and send it @TO,@CC,@Subject,@Message

    Make sure the @server variable is set to the mail server I.P

    Create procedure sp_mail

    @TO varchar(8000),

    @cc varchar(8000),

    @Subject varchar(500),

    @Message varchar(8000)

    as

    declare @rc int

    exec @rc = master.dbo.xp_smtp_sendmail

    @FROM = N' ', --Your email add

    @FROM_NAME = N' ', --Add name to address

    @replyto = N'',

    @TO = @TO,

    @cc = @cc,

    @BCC = N'',

    @priority = N'NORMAL',

    @subject =@Subject,

    @type = N'text/plain',

    @message =@Message,

    @messagefile= N'',

    @attachment = N'',

    @attachments= N'',

    @codepage = 0,

    @timeout = 10000,

    @server = ' ' --add mail server i.p here