Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Backup completion Notification using smtp

 
   Database Help (Home) -> Tools RSS
Next:  Converting Non-clustered Index to Clustered  
Author Message
opokad06

External


Since: Apr 22, 2008
Posts: 25



(Msg. 1) Posted: Thu Nov 20, 2008 12:16 pm
Post subject: Backup completion Notification using smtp
Archived from groups: microsoft>public>sqlserver>tools (more info?)

Also I am trying to sending backup notification using smtp.
This is the code I am using..

-------------------------------------

CREATE PROCEDURE [dbo].[Sample_sp_send_cdosysmail]

@From varchar(100) ,
@To varchar(100) ,
@Subject varchar(100)=" ",
@Body varchar(4000) =" "

/******************************************

This stored procedure takes the parameters and
sends an e-mail. All the mail configurations are
hard-coded in the stored procedure. Comments are
added to the stored procedure where necessary.
References to the CDOSYS objects are at the following
MSDN Web site: http://msdn.microsoft.com/library/default.asp?url=/
library/en-us/cdosys/html/_cdosys_messaging.asp

*******************************************/

AS Declare @iMsg int Declare @hr int Declare @source varchar(255) Declare
@description varchar(500) Declare @output varchar(1000)

--***** Create the CDO.Message Object *****

EXEC @hr = sp_OACreate 'CDO.Message', @iMsg OUT

--*****Configuring the Message Object *****

-- This is to configure a remote SMTP server.
--
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosy...tml/_cd
EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields
("http://schemas.microsoft.com/cdo/configuration/sendusing").Value','2'

-- This is to configure the Server Name or IP address.


-- Replace MailServerName by the name or IP of your SMTP Server.
EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.
microsoft.com/cdo/configuration/smtpserver").Value', 'smtp.va.gov'

-- Save the configurations to the message object.
EXEC @hr = sp_OAMethod @iMsg, 'Configuration.Fields.Update', null


-- Set the e-mail parameters.
EXEC @hr = sp_OASetProperty @iMsg, 'To', @To
EXEC @hr = sp_OASetProperty @iMsg, 'From', @From
EXEC @hr = sp_OASetProperty @iMsg, 'Subject', @Subject


-- If you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'.
EXEC @hr = sp_OASetProperty @iMsg, 'TextBody', @Body
EXEC @hr = sp_OAMethod @iMsg, 'Send', NULL


-- Sample error handling.


IF @hr <>0
select @hr
BEGIN
EXEC @hr = sp_OAGetErrorInfo NULL, @source OUT, @description OUT
IF @hr = 0
BEGIN
SELECT @output = ' Source: ' + @source
PRINT @output
SELECT @output = ' Description: ' + @description
PRINT @output
END
ELSE
BEGIN
PRINT ' sp_OAGetErrorInfo failed.'
RETURN
END
END
-- Do some error handling after each step if you have to.
-- Clean up the objects created.
EXEC @hr = sp_OADestroy @iMsg
GO



I did change the Mail Server name to the smtp server name but I go not get
any mail messages when I execute the stored procedure.

Sample_sp_send_cdosysmail] 'test@aol.com', 'test2@aol.com', 'testing mail
notification', 'that's cool'

What am I doing wrong? response greatly appreciated.

--
KPoku

 >> Stay informed about: Backup completion Notification using smtp 
Back to top
Login to vote
Mohit K. Gupta

External


Since: Jun 13, 2008
Posts: 41



(Msg. 2) Posted: Sun Nov 23, 2008 10:53 pm
Post subject: RE: Backup completion Notification using smtp [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I am taking a guess you are using SQL Server 2000.

Try using XPSMTP. http://www.sqldev.net/xp/xpsmtp.htm

It is alot more simplier and you don't have to have Outlook installed on the
server. Works without issue with SP3, SP3a, SP4.

Thanks.
--
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCITP: Database Administrator
MCTS: SQL Server 2005
http://sqllearnings.blogspot.com/


"opokad06" wrote:

> Also I am trying to sending backup notification using smtp.
> This is the code I am using..
>
> -------------------------------------
>
> CREATE PROCEDURE [dbo].[Sample_sp_send_cdosysmail]
>
> @From varchar(100) ,
> @To varchar(100) ,
> @Subject varchar(100)=" ",
> @Body varchar(4000) =" "
>
> /******************************************
>
> This stored procedure takes the parameters and
> sends an e-mail. All the mail configurations are
> hard-coded in the stored procedure. Comments are
> added to the stored procedure where necessary.
> References to the CDOSYS objects are at the following
> MSDN Web site: http://msdn.microsoft.com/library/default.asp?url=/
> library/en-us/cdosys/html/_cdosys_messaging.asp
>
> *******************************************/
>
> AS Declare @iMsg int Declare @hr int Declare @source varchar(255) Declare
> @description varchar(500) Declare @output varchar(1000)
>
> --***** Create the CDO.Message Object *****
>
> EXEC @hr = sp_OACreate 'CDO.Message', @iMsg OUT
>
> --*****Configuring the Message Object *****
>
> -- This is to configure a remote SMTP server.
> --
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosy...tml/_cd
> EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields
> ("http://schemas.microsoft.com/cdo/configuration/sendusing").Value','2'
>
> -- This is to configure the Server Name or IP address.
>
>
> -- Replace MailServerName by the name or IP of your SMTP Server.
> EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.
> microsoft.com/cdo/configuration/smtpserver").Value', 'smtp.va.gov'
>
> -- Save the configurations to the message object.
> EXEC @hr = sp_OAMethod @iMsg, 'Configuration.Fields.Update', null
>
>
> -- Set the e-mail parameters.
> EXEC @hr = sp_OASetProperty @iMsg, 'To', @To
> EXEC @hr = sp_OASetProperty @iMsg, 'From', @From
> EXEC @hr = sp_OASetProperty @iMsg, 'Subject', @Subject
>
>
> -- If you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'.
> EXEC @hr = sp_OASetProperty @iMsg, 'TextBody', @Body
> EXEC @hr = sp_OAMethod @iMsg, 'Send', NULL
>
>
> -- Sample error handling.
>
>
> IF @hr <>0
> select @hr
> BEGIN
> EXEC @hr = sp_OAGetErrorInfo NULL, @source OUT, @description OUT
> IF @hr = 0
> BEGIN
> SELECT @output = ' Source: ' + @source
> PRINT @output
> SELECT @output = ' Description: ' + @description
> PRINT @output
> END
> ELSE
> BEGIN
> PRINT ' sp_OAGetErrorInfo failed.'
> RETURN
> END
> END
> -- Do some error handling after each step if you have to.
> -- Clean up the objects created.
> EXEC @hr = sp_OADestroy @iMsg
> GO
>
>
>
> I did change the Mail Server name to the smtp server name but I go not get
> any mail messages when I execute the stored procedure.
>
> Sample_sp_send_cdosysmail] 'test@aol.com', 'test2@aol.com', 'testing mail
> notification', 'that's cool'
>
> What am I doing wrong? response greatly appreciated.
>
> --
> KPoku

 >> Stay informed about: Backup completion Notification using smtp 
Back to top
Login to vote
opokad06

External


Since: Apr 22, 2008
Posts: 25



(Msg. 3) Posted: Mon Nov 24, 2008 6:55 am
Post subject: RE: Backup completion Notification using smtp [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks Mohit, I am using SQL Server 2000. I will take a look at the site and
let you know how it goes.
--
KPoku


"Mohit K. Gupta" wrote:

> I am taking a guess you are using SQL Server 2000.
>
> Try using XPSMTP. http://www.sqldev.net/xp/xpsmtp.htm
>
> It is alot more simplier and you don't have to have Outlook installed on the
> server. Works without issue with SP3, SP3a, SP4.
>
> Thanks.
> --
> Mohit K. Gupta
> B.Sc. CS, Minor Japanese
> MCITP: Database Administrator
> MCTS: SQL Server 2005
> http://sqllearnings.blogspot.com/
>
>
> "opokad06" wrote:
>
> > Also I am trying to sending backup notification using smtp.
> > This is the code I am using..
> >
> > -------------------------------------
> >
> > CREATE PROCEDURE [dbo].[Sample_sp_send_cdosysmail]
> >
> > @From varchar(100) ,
> > @To varchar(100) ,
> > @Subject varchar(100)=" ",
> > @Body varchar(4000) =" "
> >
> > /******************************************
> >
> > This stored procedure takes the parameters and
> > sends an e-mail. All the mail configurations are
> > hard-coded in the stored procedure. Comments are
> > added to the stored procedure where necessary.
> > References to the CDOSYS objects are at the following
> > MSDN Web site: http://msdn.microsoft.com/library/default.asp?url=/
> > library/en-us/cdosys/html/_cdosys_messaging.asp
> >
> > *******************************************/
> >
> > AS Declare @iMsg int Declare @hr int Declare @source varchar(255) Declare
> > @description varchar(500) Declare @output varchar(1000)
> >
> > --***** Create the CDO.Message Object *****
> >
> > EXEC @hr = sp_OACreate 'CDO.Message', @iMsg OUT
> >
> > --*****Configuring the Message Object *****
> >
> > -- This is to configure a remote SMTP server.
> > --
> > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosy...tml/_cd
> > EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields
> > ("http://schemas.microsoft.com/cdo/configuration/sendusing").Value','2'
> >
> > -- This is to configure the Server Name or IP address.
> >
> >
> > -- Replace MailServerName by the name or IP of your SMTP Server.
> > EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.
> > microsoft.com/cdo/configuration/smtpserver").Value', 'smtp.va.gov'
> >
> > -- Save the configurations to the message object.
> > EXEC @hr = sp_OAMethod @iMsg, 'Configuration.Fields.Update', null
> >
> >
> > -- Set the e-mail parameters.
> > EXEC @hr = sp_OASetProperty @iMsg, 'To', @To
> > EXEC @hr = sp_OASetProperty @iMsg, 'From', @From
> > EXEC @hr = sp_OASetProperty @iMsg, 'Subject', @Subject
> >
> >
> > -- If you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'.
> > EXEC @hr = sp_OASetProperty @iMsg, 'TextBody', @Body
> > EXEC @hr = sp_OAMethod @iMsg, 'Send', NULL
> >
> >
> > -- Sample error handling.
> >
> >
> > IF @hr <>0
> > select @hr
> > BEGIN
> > EXEC @hr = sp_OAGetErrorInfo NULL, @source OUT, @description OUT
> > IF @hr = 0
> > BEGIN
> > SELECT @output = ' Source: ' + @source
> > PRINT @output
> > SELECT @output = ' Description: ' + @description
> > PRINT @output
> > END
> > ELSE
> > BEGIN
> > PRINT ' sp_OAGetErrorInfo failed.'
> > RETURN
> > END
> > END
> > -- Do some error handling after each step if you have to.
> > -- Clean up the objects created.
> > EXEC @hr = sp_OADestroy @iMsg
> > GO
> >
> >
> >
> > I did change the Mail Server name to the smtp server name but I go not get
> > any mail messages when I execute the stored procedure.
> >
> > Sample_sp_send_cdosysmail] 'test@aol.com', 'test2@aol.com', 'testing mail
> > notification', 'that's cool'
> >
> > What am I doing wrong? response greatly appreciated.
> >
> > --
> > KPoku
 >> Stay informed about: Backup completion Notification using smtp 
Back to top
Login to vote
opokad06

External


Since: Apr 22, 2008
Posts: 25



(Msg. 4) Posted: Fri Dec 05, 2008 1:04 pm
Post subject: RE: Backup completion Notification using smtp [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

One of our weekly integrity checks failed and no one new about that..
hardware failure cause the problem. I need a script that will send cdosysmail
about weekly integrity jobs when they complete or fail..
Can you help with that.

Thanks.
--
KPoku


"Mohit K. Gupta" wrote:

> I am taking a guess you are using SQL Server 2000.
>
> Try using XPSMTP. http://www.sqldev.net/xp/xpsmtp.htm
>
> It is alot more simplier and you don't have to have Outlook installed on the
> server. Works without issue with SP3, SP3a, SP4.
>
> Thanks.
> --
> Mohit K. Gupta
> B.Sc. CS, Minor Japanese
> MCITP: Database Administrator
> MCTS: SQL Server 2005
> http://sqllearnings.blogspot.com/
>
>
> "opokad06" wrote:
>
> > Also I am trying to sending backup notification using smtp.
> > This is the code I am using..
> >
> > -------------------------------------
> >
> > CREATE PROCEDURE [dbo].[Sample_sp_send_cdosysmail]
> >
> > @From varchar(100) ,
> > @To varchar(100) ,
> > @Subject varchar(100)=" ",
> > @Body varchar(4000) =" "
> >
> > /******************************************
> >
> > This stored procedure takes the parameters and
> > sends an e-mail. All the mail configurations are
> > hard-coded in the stored procedure. Comments are
> > added to the stored procedure where necessary.
> > References to the CDOSYS objects are at the following
> > MSDN Web site: http://msdn.microsoft.com/library/default.asp?url=/
> > library/en-us/cdosys/html/_cdosys_messaging.asp
> >
> > *******************************************/
> >
> > AS Declare @iMsg int Declare @hr int Declare @source varchar(255) Declare
> > @description varchar(500) Declare @output varchar(1000)
> >
> > --***** Create the CDO.Message Object *****
> >
> > EXEC @hr = sp_OACreate 'CDO.Message', @iMsg OUT
> >
> > --*****Configuring the Message Object *****
> >
> > -- This is to configure a remote SMTP server.
> > --
> > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosy...tml/_cd
> > EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields
> > ("http://schemas.microsoft.com/cdo/configuration/sendusing").Value','2'
> >
> > -- This is to configure the Server Name or IP address.
> >
> >
> > -- Replace MailServerName by the name or IP of your SMTP Server.
> > EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.
> > microsoft.com/cdo/configuration/smtpserver").Value', 'smtp.va.gov'
> >
> > -- Save the configurations to the message object.
> > EXEC @hr = sp_OAMethod @iMsg, 'Configuration.Fields.Update', null
> >
> >
> > -- Set the e-mail parameters.
> > EXEC @hr = sp_OASetProperty @iMsg, 'To', @To
> > EXEC @hr = sp_OASetProperty @iMsg, 'From', @From
> > EXEC @hr = sp_OASetProperty @iMsg, 'Subject', @Subject
> >
> >
> > -- If you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'.
> > EXEC @hr = sp_OASetProperty @iMsg, 'TextBody', @Body
> > EXEC @hr = sp_OAMethod @iMsg, 'Send', NULL
> >
> >
> > -- Sample error handling.
> >
> >
> > IF @hr <>0
> > select @hr
> > BEGIN
> > EXEC @hr = sp_OAGetErrorInfo NULL, @source OUT, @description OUT
> > IF @hr = 0
> > BEGIN
> > SELECT @output = ' Source: ' + @source
> > PRINT @output
> > SELECT @output = ' Description: ' + @description
> > PRINT @output
> > END
> > ELSE
> > BEGIN
> > PRINT ' sp_OAGetErrorInfo failed.'
> > RETURN
> > END
> > END
> > -- Do some error handling after each step if you have to.
> > -- Clean up the objects created.
> > EXEC @hr = sp_OADestroy @iMsg
> > GO
> >
> >
> >
> > I did change the Mail Server name to the smtp server name but I go not get
> > any mail messages when I execute the stored procedure.
> >
> > Sample_sp_send_cdosysmail] 'test@aol.com', 'test2@aol.com', 'testing mail
> > notification', 'that's cool'
> >
> > What am I doing wrong? response greatly appreciated.
> >
> > --
> > KPoku
 >> Stay informed about: Backup completion Notification using smtp 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
restore sql 2000 backup.bak to sql 2005 database fail - Any one konw the step how to restore sql 2000 database to sql 2005 i got error when i restore backup.bak(backup from sql 2000) file to sql 2005 i right click then choose task , restore

SQL Backup using SQL Server Management Studio Not Working - Any time we try to create a backup of a database using any method, including the backup option on the All Tasks menu, the backup never starts but just sits there with the word executing. We have made backups and I am not sure what would have changed....

[MS Design Tools] - Class Not Registered - On a Windows 2000 pro workstation I am using SQL 2000 enterprise manager I am trying to return all rows, I get the error message "An unexpected error happened during this operation. [MS Design Tools] - Class not registered." I have reinstalle...

Exporting ToExcel file - Hi, I have a SP that adds an Excel file as a linked server, then tries to send the result of a query into this file. I get the following error : ------------ OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. Authentication failed. Insert..

Importing MS Access queries and relationships to MS SQL Se.. - Dear fellow programmers, I am having a big problem on how to import queries and relationships from MS Access to SQL Server. Any suggestions will be a great help & will be appreciated. Thanks in advance, Jeri
   Database Help (Home) -> Tools All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]