OVH Cloud OVH Cloud

SP_send_cdosysmail

1 réponse
Avatar
Daniel
Bonsoir,

J'ai mis en place la proc sp_send_cdosysmail. Sur l'erreur d'un job,
j'exécute ceci :

declare @date varchar(18), @heure varchar(18), @job varchar(100), @body
varchar(4000), @path varchar(3000)
select @path= 'Dans Enterprise Manager aller dans Management SQL Server
Agent Job'
select @job = 'ADC_sysprocesses'
select @date =convert(varchar(18),getdate(),103)
select @heure =convert(varchar(18),getdate(),108)
select @body = @path + CHAR(13) + @job + CHAR(13) + CHAR(13) +@date + ' '
+ @heure
exec sp_send_cdosysmail 'PUCCINI', 'dbako@fluxus.net', 'ORAL5-006 - ADC -
PUCCINI - master',
@body

Voici la proc
CREATE PROCEDURE [dbo].[sp_send_cdosysmail]
@From varchar(100) ,
@To varchar(100) ,
@Subject varchar(100)=" ",
@Body varchar(4000) =" "

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


***********************************************************************/
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.
EXEC @hr = sp_OASetProperty @iMsg,
'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendusing").Value','212.121.182.129'
-- 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', 'MailServerName'

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

Elle marche sur un serveur, mais sur un autre non, il n'y a pas de message
d'erreur et les flux vers le SMTP remote sont ouverts.

Auriez-vous une idée?

Merci

Daniel

1 réponse

Avatar
Med Bouchenafa
Connecte toi par l'analyseur de requêtes sur chacun des deux postes avec le
même compte
Execute une à une et dans l'ordre, les instructions de ta SP.
Tu obtiendras peut-être une piste qui mettra sur la voie


--
Bien cordialement
Med Bouchenafa

"Daniel" a écrit dans le message de news:

Bonsoir,

J'ai mis en place la proc sp_send_cdosysmail. Sur l'erreur d'un job,
j'exécute ceci :

declare @date varchar(18), @heure varchar(18), @job varchar(100), @body
varchar(4000), @path varchar(3000)
select @path= 'Dans Enterprise Manager aller dans Management SQL Server
Agent Job'
select @job = 'ADC_sysprocesses'
select @date =convert(varchar(18),getdate(),103)
select @heure =convert(varchar(18),getdate(),108)
select @body = @path + CHAR(13) + @job + CHAR(13) + CHAR(13) +@date + '
'
+ @heure
exec sp_send_cdosysmail 'PUCCINI', '', 'ORAL5-006 - ADC -
PUCCINI - master',
@body

Voici la proc
CREATE PROCEDURE [dbo].[sp_send_cdosysmail]
@From varchar(100) ,
@To varchar(100) ,
@Subject varchar(100)=" ",
@Body varchar(4000) =" "

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


***********************************************************************/
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.
EXEC @hr = sp_OASetProperty @iMsg,
'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendusing").Value','212.121.182.129'
-- 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',
'MailServerName'

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

Elle marche sur un serveur, mais sur un autre non, il n'y a pas de message
d'erreur et les flux vers le SMTP remote sont ouverts.

Auriez-vous une idée?

Merci

Daniel