Send email from a batch file from command prompt

  • Hi Gurus,

    I need to create a a batch file which will send an email notification to all the sysadmin that we are shuting the SQL Server. I am not able to use xp_smtp_sendmail. Iam writing this tsql in the Query analyzer but receive the following error.

    Query:

    declare @rc int

    exec @rc = master.dbo.xp_smtp_sendmail

    @FROM = N'MyEmail@MyDomain.com',

    @FROM_NAME = N'Joe Mailman',

    @TO = N'mamin@sapient.com.com',

    @cc = N'MyOtherFriend@HisDomain.com',

    @BCC = N'MyEmail@MyDomain.com',

    @priority = N'HIGH',

    @subject = N'Hello SQL Server SMTP Mail',

    @message = N'Goodbye MAPI, goodbye Outlook',

    @type = N'text/plain',

    @attachments= N'c:\attachment1.txt;c:\attachment2.txt',

    @server = N'mail.mydomain.com' -- my company'd relaymail id

    select RC = @rc

    go

    Error:

    ========

    Msg 2812, Level 16, State 62, Line 2

    Could not find stored procedure 'master.dbo.xp_smtp_sendmail'.

    Please help me out to achive my goal. Need to send an email from a batch file regarding the server outage.

    Please help !!!

    "More Green More Oxygen !! Plant a tree today"

  • xp_smtp_sendmail is not a system extended stored procedure that comes with SQL Server.

    I think it is a third-party product that you need to install.

    Why wouldn't you use database mail (which uses SMTP)? IT ships with SQL Server.

  • If you are using SQL Server 2005 you have 2 procedures:- msdb.dbo.sp_send_dbmail and sys.xp_sendmail.

    Database Mail is easy enough to set up to use the msdb.dbo.sp_send_dbmail procedure.

    Facts are stubborn things, but statistics are more pliable - Mark Twain
    Carolyn
    SQLServerSpecialists[/url]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply