Automating Job with email notification

  • 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"

  • Take a look at these two sites:

    http://articles.techrepublic.com.com/5100-10878_11-6161839.html#

    http://msdn.microsoft.com/en-us/library/ms190307.aspx

    I am using the sp_send_dbmail to send emails for my Automated Unit Testing. I have not had much problems with it. I have it setup with a job using the SQL Server agent to run the unit tests and then send out an email if any of the unit tests failed. And it can be scheduled to run as often as you need it to. Hope this helps.

    Cheers,

    Anshu

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

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