Bonjour,
Configuration : Windows 2000 server SP4 et SQL2000 SP4
J'ai besoin d'installer un client MAPI pour créer un profil utilisable par
sqlmail afin d'utliser master.dbo.xp_sendmail
Est-il possible d'installer quelque chose de moins "lourd" que Outlook ?
Et si oui quoi et comment créer le profil ?
Merci
Bonjour,
Configuration : Windows 2000 server SP4 et SQL2000 SP4
J'ai besoin d'installer un client MAPI pour créer un profil utilisable par
sqlmail afin d'utliser master.dbo.xp_sendmail
Est-il possible d'installer quelque chose de moins "lourd" que Outlook ?
Et si oui quoi et comment créer le profil ?
Merci
Bonjour,
Configuration : Windows 2000 server SP4 et SQL2000 SP4
J'ai besoin d'installer un client MAPI pour créer un profil utilisable par
sqlmail afin d'utliser master.dbo.xp_sendmail
Est-il possible d'installer quelque chose de moins "lourd" que Outlook ?
Et si oui quoi et comment créer le profil ?
Merci
Non il faut outlook et c'est la tout le probleme
SQL2005 fournit une solution Database Mail basée sur SMTP et ne
aucune install de client messagerie
hch
"jack" wrote:
> Bonjour,
>
> Configuration : Windows 2000 server SP4 et SQL2000 SP4
>
> J'ai besoin d'installer un client MAPI pour créer un profil utilisable
> sqlmail afin d'utliser master.dbo.xp_sendmail
>
> Est-il possible d'installer quelque chose de moins "lourd" que Outlook ?
> Et si oui quoi et comment créer le profil ?
>
> Merci
>
>
>
Non il faut outlook et c'est la tout le probleme
SQL2005 fournit une solution Database Mail basée sur SMTP et ne
aucune install de client messagerie
hch
"jack" wrote:
> Bonjour,
>
> Configuration : Windows 2000 server SP4 et SQL2000 SP4
>
> J'ai besoin d'installer un client MAPI pour créer un profil utilisable
> sqlmail afin d'utliser master.dbo.xp_sendmail
>
> Est-il possible d'installer quelque chose de moins "lourd" que Outlook ?
> Et si oui quoi et comment créer le profil ?
>
> Merci
>
>
>
Non il faut outlook et c'est la tout le probleme
SQL2005 fournit une solution Database Mail basée sur SMTP et ne
aucune install de client messagerie
hch
"jack" wrote:
> Bonjour,
>
> Configuration : Windows 2000 server SP4 et SQL2000 SP4
>
> J'ai besoin d'installer un client MAPI pour créer un profil utilisable
> sqlmail afin d'utliser master.dbo.xp_sendmail
>
> Est-il possible d'installer quelque chose de moins "lourd" que Outlook ?
> Et si oui quoi et comment créer le profil ?
>
> Merci
>
>
>
Bonjour,
Configuration : Windows 2000 server SP4 et SQL2000 SP4
J'ai besoin d'installer un client MAPI pour créer un profil utilisable par
sqlmail afin d'utliser master.dbo.xp_sendmail
Est-il possible d'installer quelque chose de moins "lourd" que Outlook ?
Et si oui quoi et comment créer le profil ?
Merci
Bonjour,
Configuration : Windows 2000 server SP4 et SQL2000 SP4
J'ai besoin d'installer un client MAPI pour créer un profil utilisable par
sqlmail afin d'utliser master.dbo.xp_sendmail
Est-il possible d'installer quelque chose de moins "lourd" que Outlook ?
Et si oui quoi et comment créer le profil ?
Merci
Bonjour,
Configuration : Windows 2000 server SP4 et SQL2000 SP4
J'ai besoin d'installer un client MAPI pour créer un profil utilisable par
sqlmail afin d'utliser master.dbo.xp_sendmail
Est-il possible d'installer quelque chose de moins "lourd" que Outlook ?
Et si oui quoi et comment créer le profil ?
Merci
Il est possible avec SQL 2000, d'envoyer des mail sans utiliser
Ci-dessous une procédure que j'utilise avec succès.
Aucun client de messagerie n'est requis.
http://support.microsoft.com/kb/312839
Daniel
CREATE PROCEDURE [dbo].[sp_send_cdosysmail]
@From varchar(100) ,
@To varchar(100) ,
@Subject varchar(100)=" ",
@Body varchar(4000) =" "
/*********************************************************************
This stored procedure takes the above parameters and sends an e-mail.
All of the mail configurations are hard-coded in the stored procedure.
Comments are added to the stored procedure where necessary.
Reference to the CDOSYS objects are at the following MSDN Web site:
***********************************************************************/
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,
-- 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,
'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 need to.
-- Clean up the objects created.
EXEC @hr = sp_OADestroy @iMsg
go
Ensuite, utilisez la procédure stockée que vous avez créée et fournissez
paramètres corrects :
declare @Body varchar(4000)
select @Body = 'This is a Test Message'
exec sp_send_cdosysmail
'','','Test of CDOSYS',@Body
"jack" a écrit dans le message de news:
%
> Bonjour,
>
> Configuration : Windows 2000 server SP4 et SQL2000 SP4
>
> J'ai besoin d'installer un client MAPI pour créer un profil utilisable
> sqlmail afin d'utliser master.dbo.xp_sendmail
>
> Est-il possible d'installer quelque chose de moins "lourd" que Outlook ?
> Et si oui quoi et comment créer le profil ?
>
> Merci
>
>
Il est possible avec SQL 2000, d'envoyer des mail sans utiliser
Ci-dessous une procédure que j'utilise avec succès.
Aucun client de messagerie n'est requis.
http://support.microsoft.com/kb/312839
Daniel
CREATE PROCEDURE [dbo].[sp_send_cdosysmail]
@From varchar(100) ,
@To varchar(100) ,
@Subject varchar(100)=" ",
@Body varchar(4000) =" "
/*********************************************************************
This stored procedure takes the above parameters and sends an e-mail.
All of the mail configurations are hard-coded in the stored procedure.
Comments are added to the stored procedure where necessary.
Reference to the CDOSYS objects are at the following MSDN Web site:
***********************************************************************/
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,
-- 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,
'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 need to.
-- Clean up the objects created.
EXEC @hr = sp_OADestroy @iMsg
go
Ensuite, utilisez la procédure stockée que vous avez créée et fournissez
paramètres corrects :
declare @Body varchar(4000)
select @Body = 'This is a Test Message'
exec sp_send_cdosysmail
'someone@microsoft.com','someone2@microsoft.com','Test of CDOSYS',@Body
"jack" <jack@lcbd.fr> a écrit dans le message de news:
%23RK2m2hyIHA.4772@TK2MSFTNGP03.phx.gbl...
> Bonjour,
>
> Configuration : Windows 2000 server SP4 et SQL2000 SP4
>
> J'ai besoin d'installer un client MAPI pour créer un profil utilisable
> sqlmail afin d'utliser master.dbo.xp_sendmail
>
> Est-il possible d'installer quelque chose de moins "lourd" que Outlook ?
> Et si oui quoi et comment créer le profil ?
>
> Merci
>
>
Il est possible avec SQL 2000, d'envoyer des mail sans utiliser
Ci-dessous une procédure que j'utilise avec succès.
Aucun client de messagerie n'est requis.
http://support.microsoft.com/kb/312839
Daniel
CREATE PROCEDURE [dbo].[sp_send_cdosysmail]
@From varchar(100) ,
@To varchar(100) ,
@Subject varchar(100)=" ",
@Body varchar(4000) =" "
/*********************************************************************
This stored procedure takes the above parameters and sends an e-mail.
All of the mail configurations are hard-coded in the stored procedure.
Comments are added to the stored procedure where necessary.
Reference to the CDOSYS objects are at the following MSDN Web site:
***********************************************************************/
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,
-- 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,
'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 need to.
-- Clean up the objects created.
EXEC @hr = sp_OADestroy @iMsg
go
Ensuite, utilisez la procédure stockée que vous avez créée et fournissez
paramètres corrects :
declare @Body varchar(4000)
select @Body = 'This is a Test Message'
exec sp_send_cdosysmail
'','','Test of CDOSYS',@Body
"jack" a écrit dans le message de news:
%
> Bonjour,
>
> Configuration : Windows 2000 server SP4 et SQL2000 SP4
>
> J'ai besoin d'installer un client MAPI pour créer un profil utilisable
> sqlmail afin d'utliser master.dbo.xp_sendmail
>
> Est-il possible d'installer quelque chose de moins "lourd" que Outlook ?
> Et si oui quoi et comment créer le profil ?
>
> Merci
>
>
Merci.
Et j'imagine que si l'on a des pièces jointes il faut ajouter cela
EXEC @hr = sp_OAMethod @object, 'AddAttachment', NULL, 'c:myfile.txt'
"Daniel Eyer" wrote in message
news:484f89e2$0$864$Il est possible avec SQL 2000, d'envoyer des mail sans utiliser
xp_sendmail.Ci-dessous une procédure que j'utilise avec succès.
Aucun client de messagerie n'est requis.
http://support.microsoft.com/kb/312839
Daniel
CREATE PROCEDURE [dbo].[sp_send_cdosysmail]
@From varchar(100) ,
@To varchar(100) ,
@Subject varchar(100)=" ",
@Body varchar(4000) =" "
/*********************************************************************
This stored procedure takes the above parameters and sends an e-mail.
All of the mail configurations are hard-coded in the stored procedure.
Comments are added to the stored procedure where necessary.
Reference 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" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">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/cdosys/html/_cdosys_schema_configuration_sendusing.asp" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_schema_configuration_sendusing.aspEXEC @hr = sp_OASetProperty @iMsg,
'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendus
ing").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/smtpse
rver").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 need to.
-- Clean up the objects created.
EXEC @hr = sp_OADestroy @iMsg
go
Ensuite, utilisez la procédure stockée que vous avez créée et fournissez
lesparamètres corrects :
declare @Body varchar(4000)
select @Body = 'This is a Test Message'
exec sp_send_cdosysmail
'','','Test of CDOSYS',@Body
"jack" a écrit dans le message de news:
%
> Bonjour,
>
> Configuration : Windows 2000 server SP4 et SQL2000 SP4
>
> J'ai besoin d'installer un client MAPI pour créer un profil utilisable
par> sqlmail afin d'utliser master.dbo.xp_sendmail
>
> Est-il possible d'installer quelque chose de moins "lourd" que Outlook
> ?
> Et si oui quoi et comment créer le profil ?
>
> Merci
>
>
Merci.
Et j'imagine que si l'on a des pièces jointes il faut ajouter cela
EXEC @hr = sp_OAMethod @object, 'AddAttachment', NULL, 'c:myfile.txt'
"Daniel Eyer" <daniel.eyer@free.fr> wrote in message
news:484f89e2$0$864$ba4acef3@news.orange.fr...
Il est possible avec SQL 2000, d'envoyer des mail sans utiliser
xp_sendmail.
Ci-dessous une procédure que j'utilise avec succès.
Aucun client de messagerie n'est requis.
http://support.microsoft.com/kb/312839
Daniel
CREATE PROCEDURE [dbo].[sp_send_cdosysmail]
@From varchar(100) ,
@To varchar(100) ,
@Subject varchar(100)=" ",
@Body varchar(4000) =" "
/*********************************************************************
This stored procedure takes the above parameters and sends an e-mail.
All of the mail configurations are hard-coded in the stored procedure.
Comments are added to the stored procedure where necessary.
Reference 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/cdosys/html/_cdosys_schema_configuration_sendusing.asp
EXEC @hr = sp_OASetProperty @iMsg,
'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendus
ing").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/smtpse
rver").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 need to.
-- Clean up the objects created.
EXEC @hr = sp_OADestroy @iMsg
go
Ensuite, utilisez la procédure stockée que vous avez créée et fournissez
les
paramètres corrects :
declare @Body varchar(4000)
select @Body = 'This is a Test Message'
exec sp_send_cdosysmail
'someone@microsoft.com','someone2@microsoft.com','Test of CDOSYS',@Body
"jack" <jack@lcbd.fr> a écrit dans le message de news:
%23RK2m2hyIHA.4772@TK2MSFTNGP03.phx.gbl...
> Bonjour,
>
> Configuration : Windows 2000 server SP4 et SQL2000 SP4
>
> J'ai besoin d'installer un client MAPI pour créer un profil utilisable
par
> sqlmail afin d'utliser master.dbo.xp_sendmail
>
> Est-il possible d'installer quelque chose de moins "lourd" que Outlook
> ?
> Et si oui quoi et comment créer le profil ?
>
> Merci
>
>
Merci.
Et j'imagine que si l'on a des pièces jointes il faut ajouter cela
EXEC @hr = sp_OAMethod @object, 'AddAttachment', NULL, 'c:myfile.txt'
"Daniel Eyer" wrote in message
news:484f89e2$0$864$Il est possible avec SQL 2000, d'envoyer des mail sans utiliser
xp_sendmail.Ci-dessous une procédure que j'utilise avec succès.
Aucun client de messagerie n'est requis.
http://support.microsoft.com/kb/312839
Daniel
CREATE PROCEDURE [dbo].[sp_send_cdosysmail]
@From varchar(100) ,
@To varchar(100) ,
@Subject varchar(100)=" ",
@Body varchar(4000) =" "
/*********************************************************************
This stored procedure takes the above parameters and sends an e-mail.
All of the mail configurations are hard-coded in the stored procedure.
Comments are added to the stored procedure where necessary.
Reference 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" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">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/cdosys/html/_cdosys_schema_configuration_sendusing.asp" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_schema_configuration_sendusing.aspEXEC @hr = sp_OASetProperty @iMsg,
'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendus
ing").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/smtpse
rver").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 need to.
-- Clean up the objects created.
EXEC @hr = sp_OADestroy @iMsg
go
Ensuite, utilisez la procédure stockée que vous avez créée et fournissez
lesparamètres corrects :
declare @Body varchar(4000)
select @Body = 'This is a Test Message'
exec sp_send_cdosysmail
'','','Test of CDOSYS',@Body
"jack" a écrit dans le message de news:
%
> Bonjour,
>
> Configuration : Windows 2000 server SP4 et SQL2000 SP4
>
> J'ai besoin d'installer un client MAPI pour créer un profil utilisable
par> sqlmail afin d'utliser master.dbo.xp_sendmail
>
> Est-il possible d'installer quelque chose de moins "lourd" que Outlook
> ?
> Et si oui quoi et comment créer le profil ?
>
> Merci
>
>
C'est tout à fait ça.
Je me suis crée une procédure qui permet d'envoyer le résultat d'une requète
au format HTML. (cf ci-dessous)
Quelques limitations
- le résultat de la requète ne peut exéder 8000 caractères
- les colonnes doivent être au format texte. Pour les dates et nombre, i l
suffit d'utiliser les fonctions de convertion.
Daniel Eyer
-----------------------------------------------------------------
Create PROCEDURE [dbo].[sp_send_MailHtml]
@From varchar(128) ,
@To varchar(128) ,
@Cc varchar(128) ,
@BCc varchar(128) ,
@Subject varchar(124)=" ",
@Query varchar(4000) = " "
/*********************************************************************
This stored procedure takes the above parameters and sends an e-mail.
All of the mail configurations are hard-coded in the stored procedure.
Comments are added to the stored procedure where necessary.
Reference to the CDOSYS objects are at the following MSDN Web site:http:// msdn.microsoft.com/library/default.asp?url=/library/en-us/cdos...
***********************************************************************/
AS
--Mail declaration
Declare @iMsg int
Declare @hr int
Declare @source varchar(255)
Declare @description varchar(500)
Declare @output varchar(1000)
--HTML declaration
declare @Columns varchar(8000)
declare @ColHeader varchar(8000)
Declare @SqlCmd varchar(8000)
Declare @HTMLBody varchar(8000)
--************* 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/cdo s...
EXEC @hr = sp_OASetProperty @iMsg,
'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/send" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://schemas.microsoft.com/cdo/configuration/send using").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/smtp" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://schemas.microsoft.com/cdo/configuration/smtp server").Value',
'smtp.fr.oleane.com'
-- 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
If(@Cc Is Not Null)
Exec @hr = sp_OASetProperty @iMsg, 'Cc', @Cc
If(@BCc Is Not Null)
Exec @hr = sp_OASetProperty @iMsg, 'BCc', @BCc
EXEC @hr = sp_OASetProperty @iMsg, 'Subject', @Subject
-- If you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'.
-- EXEC @hr = sp_OASetProperty @iMsg, 'HTMLBody', @Body
/************************************************************************* /
-- drop temporary tables used.
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE name = '##TEMPhtm l1')
DROP TABLE ##TEMPhtml1
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE name = '##TEMPhtm l2')
DROP TABLE ##TEMPhtml2
-- prepare query
set @SqlCmd = 'select * into ##tempHTML1 from (' + @Query + ') as t1'
execute (@SqlCmd)
--Prepare columns details
SELECT @columns =
COALESCE(@columns + ' + ''</td><td>'' + ', '') +
'RTrim(convert(varchar(100),isnull(' + column_name +','' '')))'
FROM tempdb.information_schema.columns
where table_name='##tempHTML1'
--Prepare column Header
set @colHeader = '<tr bgcolor=#EDFEDF align=Left>'
SELECT @colHeader = @colHeader + '<td><b>' + column_name + '</b></td>'
FROM tempdb.information_schema.columns where table_name='##tempHTML1'
set @colHeader=@colHeader + '</tr>'
--prepare final output
set @SqlCmd =
'Select ''<tr><td>'' + ' +
@columns +
' ''</td></tr> '' into ##tempHTML2 from ##tempHTML1 '
execute( @SqlCmd)
-- set @finalhtmlout=
set @HtmlBody =
' <html> <body><style type="text/css" media="all"> ' +
'table { margin-bottom: 2em; border-collapse: collapse } ' +
'td,th {border= 1 solid #999; padding: 0.2em 0.2em; font-size: 12;} ' +
'</style> <table width="100%"> ' +
@colHeader
select @HtmlBody = @HtmlBody + [</td></tr>]
from ##tempHTML2
set @HtmlBody = @HtmlBody + ' </table></body></htmL>'
EXEC @hr = sp_OASetProperty @iMsg, 'HTMLBody', @HtmlBody
EXEC @hr = sp_OAMethod @iMsg, 'Send', NULL
-- drop temporary tables used.
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE name = '##TEMPhtm l1')
DROP TABLE ##TEMPhtml1
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE name = '##TEMPhtm l2')
DROP TABLE ##TEMPhtml2
/************************************************************************* /
-- 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 need to.
-- Clean up the objects created.
EXEC @hr = sp_OADestroy @iMsg
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
-----------------------------------------------------------------
"jack" a écrit dans le message de news:
> Merci.
> Et j'imagine que si l'on a des pièces jointes il faut ajouter cela
> EXEC @hr = sp_OAMethod @object, 'AddAttachment', NULL, 'c:myfile.txt'
> "Daniel Eyer" wrote in message
>news:484f89e2$0$864$
>> Il est possible avec SQL 2000, d'envoyer des mail sans utiliser
> xp_sendmail.
>> Ci-dessous une procédure que j'utilise avec succès.
>> Aucun client de messagerie n'est requis.
>>http://support.microsoft.com/kb/312839
>> Daniel
>> CREATE PROCEDURE [dbo].[sp_send_cdosysmail]
>> @From varchar(100) ,
>> @To varchar(100) ,
>> @Subject varchar(100)=" ",
>> @Body varchar(4000) =" "
>> /*********************************************************************
>> This stored procedure takes the above parameters and sends an e-mail.
>> All of the mail configurations are hard-coded in the stored procedure.
>> Comments are added to the stored procedure where necessary.
>> Reference to the CDOSYS objects are at the following MSDN Web site:
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdos.. .
>> *********************************************************************** /
>> 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/cdos.. .
>> EXEC @hr = sp_OASetProperty @iMsg,
> 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/se ndus
> ing").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/sm tpse
> rver").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 O UT
>> 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 need to.
>> -- Clean up the objects created.
>> EXEC @hr = sp_OADestroy @iMsg
>> go
>> Ensuite, utilisez la procédure stockée que vous avez créée et f ournissez
> les
>> paramètres corrects :
>> declare @Body varchar(4000)
>> select @Body = 'This is a Test Message'
>> exec sp_send_cdosysmail
>> '','','Test of CDOSYS',@Body
>> "jack" a écrit dans le message de news:
>> %
>> > Bonjour,
>> > Configuration : Windows 2000 server SP4 et SQL2000 SP4
>> > J'ai besoin d'installer un client MAPI pour créer un profil utilisa ble
> par
>> > sqlmail afin d'utliser master.dbo.xp_sendmail
>> > Est-il possible d'installer quelque chose de moins "lourd" que Outloo k
>> > ?
>> > Et si oui quoi et comment créer le profil ?
>> > Merci
C'est tout à fait ça.
Je me suis crée une procédure qui permet d'envoyer le résultat d'une requète
au format HTML. (cf ci-dessous)
Quelques limitations
- le résultat de la requète ne peut exéder 8000 caractères
- les colonnes doivent être au format texte. Pour les dates et nombre, i l
suffit d'utiliser les fonctions de convertion.
Daniel Eyer
-----------------------------------------------------------------
Create PROCEDURE [dbo].[sp_send_MailHtml]
@From varchar(128) ,
@To varchar(128) ,
@Cc varchar(128) ,
@BCc varchar(128) ,
@Subject varchar(124)=" ",
@Query varchar(4000) = " "
/*********************************************************************
This stored procedure takes the above parameters and sends an e-mail.
All of the mail configurations are hard-coded in the stored procedure.
Comments are added to the stored procedure where necessary.
Reference to the CDOSYS objects are at the following MSDN Web site:http:// msdn.microsoft.com/library/default.asp?url=/library/en-us/cdos...
***********************************************************************/
AS
--Mail declaration
Declare @iMsg int
Declare @hr int
Declare @source varchar(255)
Declare @description varchar(500)
Declare @output varchar(1000)
--HTML declaration
declare @Columns varchar(8000)
declare @ColHeader varchar(8000)
Declare @SqlCmd varchar(8000)
Declare @HTMLBody varchar(8000)
--************* 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/cdo s...
EXEC @hr = sp_OASetProperty @iMsg,
'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/send using").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/smtp server").Value',
'smtp.fr.oleane.com'
-- 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
If(@Cc Is Not Null)
Exec @hr = sp_OASetProperty @iMsg, 'Cc', @Cc
If(@BCc Is Not Null)
Exec @hr = sp_OASetProperty @iMsg, 'BCc', @BCc
EXEC @hr = sp_OASetProperty @iMsg, 'Subject', @Subject
-- If you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'.
-- EXEC @hr = sp_OASetProperty @iMsg, 'HTMLBody', @Body
/************************************************************************* /
-- drop temporary tables used.
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE name = '##TEMPhtm l1')
DROP TABLE ##TEMPhtml1
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE name = '##TEMPhtm l2')
DROP TABLE ##TEMPhtml2
-- prepare query
set @SqlCmd = 'select * into ##tempHTML1 from (' + @Query + ') as t1'
execute (@SqlCmd)
--Prepare columns details
SELECT @columns =
COALESCE(@columns + ' + ''</td><td>'' + ', '') +
'RTrim(convert(varchar(100),isnull(' + column_name +','' '')))'
FROM tempdb.information_schema.columns
where table_name='##tempHTML1'
--Prepare column Header
set @colHeader = '<tr bgcolor=#EDFEDF align=Left>'
SELECT @colHeader = @colHeader + '<td><b>' + column_name + '</b></td>'
FROM tempdb.information_schema.columns where table_name='##tempHTML1'
set @colHeader=@colHeader + '</tr>'
--prepare final output
set @SqlCmd =
'Select ''<tr><td>'' + ' +
@columns +
' ''</td></tr> '' into ##tempHTML2 from ##tempHTML1 '
execute( @SqlCmd)
-- set @finalhtmlout=
set @HtmlBody =
' <html> <body><style type="text/css" media="all"> ' +
'table { margin-bottom: 2em; border-collapse: collapse } ' +
'td,th {border= 1 solid #999; padding: 0.2em 0.2em; font-size: 12;} ' +
'</style> <table width="100%"> ' +
@colHeader
select @HtmlBody = @HtmlBody + [</td></tr>]
from ##tempHTML2
set @HtmlBody = @HtmlBody + ' </table></body></htmL>'
EXEC @hr = sp_OASetProperty @iMsg, 'HTMLBody', @HtmlBody
EXEC @hr = sp_OAMethod @iMsg, 'Send', NULL
-- drop temporary tables used.
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE name = '##TEMPhtm l1')
DROP TABLE ##TEMPhtml1
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE name = '##TEMPhtm l2')
DROP TABLE ##TEMPhtml2
/************************************************************************* /
-- 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 need to.
-- Clean up the objects created.
EXEC @hr = sp_OADestroy @iMsg
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
-----------------------------------------------------------------
"jack" <j...@lcbd.fr> a écrit dans le message de news:
eyIzbi6yIHA.5...@TK2MSFTNGP04.phx.gbl...
> Merci.
> Et j'imagine que si l'on a des pièces jointes il faut ajouter cela
> EXEC @hr = sp_OAMethod @object, 'AddAttachment', NULL, 'c:myfile.txt'
> "Daniel Eyer" <daniel.e...@free.fr> wrote in message
>news:484f89e2$0$864$ba4acef3@news.orange.fr...
>> Il est possible avec SQL 2000, d'envoyer des mail sans utiliser
> xp_sendmail.
>> Ci-dessous une procédure que j'utilise avec succès.
>> Aucun client de messagerie n'est requis.
>>http://support.microsoft.com/kb/312839
>> Daniel
>> CREATE PROCEDURE [dbo].[sp_send_cdosysmail]
>> @From varchar(100) ,
>> @To varchar(100) ,
>> @Subject varchar(100)=" ",
>> @Body varchar(4000) =" "
>> /*********************************************************************
>> This stored procedure takes the above parameters and sends an e-mail.
>> All of the mail configurations are hard-coded in the stored procedure.
>> Comments are added to the stored procedure where necessary.
>> Reference to the CDOSYS objects are at the following MSDN Web site:
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdos.. .
>> *********************************************************************** /
>> 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/cdos.. .
>> EXEC @hr = sp_OASetProperty @iMsg,
> 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/se ndus
> ing").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/sm tpse
> rver").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 O UT
>> 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 need to.
>> -- Clean up the objects created.
>> EXEC @hr = sp_OADestroy @iMsg
>> go
>> Ensuite, utilisez la procédure stockée que vous avez créée et f ournissez
> les
>> paramètres corrects :
>> declare @Body varchar(4000)
>> select @Body = 'This is a Test Message'
>> exec sp_send_cdosysmail
>> 'some...@microsoft.com','someo...@microsoft.com','Test of CDOSYS',@Body
>> "jack" <j...@lcbd.fr> a écrit dans le message de news:
>> %23RK2m2hyIHA.4...@TK2MSFTNGP03.phx.gbl...
>> > Bonjour,
>> > Configuration : Windows 2000 server SP4 et SQL2000 SP4
>> > J'ai besoin d'installer un client MAPI pour créer un profil utilisa ble
> par
>> > sqlmail afin d'utliser master.dbo.xp_sendmail
>> > Est-il possible d'installer quelque chose de moins "lourd" que Outloo k
>> > ?
>> > Et si oui quoi et comment créer le profil ?
>> > Merci
C'est tout à fait ça.
Je me suis crée une procédure qui permet d'envoyer le résultat d'une requète
au format HTML. (cf ci-dessous)
Quelques limitations
- le résultat de la requète ne peut exéder 8000 caractères
- les colonnes doivent être au format texte. Pour les dates et nombre, i l
suffit d'utiliser les fonctions de convertion.
Daniel Eyer
-----------------------------------------------------------------
Create PROCEDURE [dbo].[sp_send_MailHtml]
@From varchar(128) ,
@To varchar(128) ,
@Cc varchar(128) ,
@BCc varchar(128) ,
@Subject varchar(124)=" ",
@Query varchar(4000) = " "
/*********************************************************************
This stored procedure takes the above parameters and sends an e-mail.
All of the mail configurations are hard-coded in the stored procedure.
Comments are added to the stored procedure where necessary.
Reference to the CDOSYS objects are at the following MSDN Web site:http:// msdn.microsoft.com/library/default.asp?url=/library/en-us/cdos...
***********************************************************************/
AS
--Mail declaration
Declare @iMsg int
Declare @hr int
Declare @source varchar(255)
Declare @description varchar(500)
Declare @output varchar(1000)
--HTML declaration
declare @Columns varchar(8000)
declare @ColHeader varchar(8000)
Declare @SqlCmd varchar(8000)
Declare @HTMLBody varchar(8000)
--************* 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/cdo s...
EXEC @hr = sp_OASetProperty @iMsg,
'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/send" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://schemas.microsoft.com/cdo/configuration/send using").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/smtp" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://schemas.microsoft.com/cdo/configuration/smtp server").Value',
'smtp.fr.oleane.com'
-- 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
If(@Cc Is Not Null)
Exec @hr = sp_OASetProperty @iMsg, 'Cc', @Cc
If(@BCc Is Not Null)
Exec @hr = sp_OASetProperty @iMsg, 'BCc', @BCc
EXEC @hr = sp_OASetProperty @iMsg, 'Subject', @Subject
-- If you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'.
-- EXEC @hr = sp_OASetProperty @iMsg, 'HTMLBody', @Body
/************************************************************************* /
-- drop temporary tables used.
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE name = '##TEMPhtm l1')
DROP TABLE ##TEMPhtml1
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE name = '##TEMPhtm l2')
DROP TABLE ##TEMPhtml2
-- prepare query
set @SqlCmd = 'select * into ##tempHTML1 from (' + @Query + ') as t1'
execute (@SqlCmd)
--Prepare columns details
SELECT @columns =
COALESCE(@columns + ' + ''</td><td>'' + ', '') +
'RTrim(convert(varchar(100),isnull(' + column_name +','' '')))'
FROM tempdb.information_schema.columns
where table_name='##tempHTML1'
--Prepare column Header
set @colHeader = '<tr bgcolor=#EDFEDF align=Left>'
SELECT @colHeader = @colHeader + '<td><b>' + column_name + '</b></td>'
FROM tempdb.information_schema.columns where table_name='##tempHTML1'
set @colHeader=@colHeader + '</tr>'
--prepare final output
set @SqlCmd =
'Select ''<tr><td>'' + ' +
@columns +
' ''</td></tr> '' into ##tempHTML2 from ##tempHTML1 '
execute( @SqlCmd)
-- set @finalhtmlout=
set @HtmlBody =
' <html> <body><style type="text/css" media="all"> ' +
'table { margin-bottom: 2em; border-collapse: collapse } ' +
'td,th {border= 1 solid #999; padding: 0.2em 0.2em; font-size: 12;} ' +
'</style> <table width="100%"> ' +
@colHeader
select @HtmlBody = @HtmlBody + [</td></tr>]
from ##tempHTML2
set @HtmlBody = @HtmlBody + ' </table></body></htmL>'
EXEC @hr = sp_OASetProperty @iMsg, 'HTMLBody', @HtmlBody
EXEC @hr = sp_OAMethod @iMsg, 'Send', NULL
-- drop temporary tables used.
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE name = '##TEMPhtm l1')
DROP TABLE ##TEMPhtml1
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE name = '##TEMPhtm l2')
DROP TABLE ##TEMPhtml2
/************************************************************************* /
-- 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 need to.
-- Clean up the objects created.
EXEC @hr = sp_OADestroy @iMsg
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
-----------------------------------------------------------------
"jack" a écrit dans le message de news:
> Merci.
> Et j'imagine que si l'on a des pièces jointes il faut ajouter cela
> EXEC @hr = sp_OAMethod @object, 'AddAttachment', NULL, 'c:myfile.txt'
> "Daniel Eyer" wrote in message
>news:484f89e2$0$864$
>> Il est possible avec SQL 2000, d'envoyer des mail sans utiliser
> xp_sendmail.
>> Ci-dessous une procédure que j'utilise avec succès.
>> Aucun client de messagerie n'est requis.
>>http://support.microsoft.com/kb/312839
>> Daniel
>> CREATE PROCEDURE [dbo].[sp_send_cdosysmail]
>> @From varchar(100) ,
>> @To varchar(100) ,
>> @Subject varchar(100)=" ",
>> @Body varchar(4000) =" "
>> /*********************************************************************
>> This stored procedure takes the above parameters and sends an e-mail.
>> All of the mail configurations are hard-coded in the stored procedure.
>> Comments are added to the stored procedure where necessary.
>> Reference to the CDOSYS objects are at the following MSDN Web site:
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdos.. .
>> *********************************************************************** /
>> 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/cdos.. .
>> EXEC @hr = sp_OASetProperty @iMsg,
> 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/se ndus
> ing").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/sm tpse
> rver").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 O UT
>> 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 need to.
>> -- Clean up the objects created.
>> EXEC @hr = sp_OADestroy @iMsg
>> go
>> Ensuite, utilisez la procédure stockée que vous avez créée et f ournissez
> les
>> paramètres corrects :
>> declare @Body varchar(4000)
>> select @Body = 'This is a Test Message'
>> exec sp_send_cdosysmail
>> '','','Test of CDOSYS',@Body
>> "jack" a écrit dans le message de news:
>> %
>> > Bonjour,
>> > Configuration : Windows 2000 server SP4 et SQL2000 SP4
>> > J'ai besoin d'installer un client MAPI pour créer un profil utilisa ble
> par
>> > sqlmail afin d'utliser master.dbo.xp_sendmail
>> > Est-il possible d'installer quelque chose de moins "lourd" que Outloo k
>> > ?
>> > Et si oui quoi et comment créer le profil ?
>> > Merci
Ma collègue Catherine Brunie et moi même avons mis au point différent
scripts en utilisant CDOsys pour ce faire :
Lisez les sur Guss.fr :
http://www.guss.fr/Accueil/Espacemembres/Touslesarticles/tabid/70/articleType/ArticleView/articleId/18/Default.aspx
A +
Ma collègue Catherine Brunie et moi même avons mis au point différent
scripts en utilisant CDOsys pour ce faire :
Lisez les sur Guss.fr :
http://www.guss.fr/Accueil/Espacemembres/Touslesarticles/tabid/70/articleType/ArticleView/articleId/18/Default.aspx
A +
Ma collègue Catherine Brunie et moi même avons mis au point différent
scripts en utilisant CDOsys pour ce faire :
Lisez les sur Guss.fr :
http://www.guss.fr/Accueil/Espacemembres/Touslesarticles/tabid/70/articleType/ArticleView/articleId/18/Default.aspx
A +
> Si vous ne démentez pas immédiatement les affirmations de "incompétent"
ou ne les prouver pas je vais peut être suivre l'exemple de Brouard et
vous demander 20000 euro pour diffamation à l'encontre de ma personne et
ma société puisque cosignataires des messages alors fournissez vos
preuves ou excuser vous . Quand aux niveaux de compétence de Fred il
n'est plus à démontrer puisque il est de notoriété publique dans les
milieux compétents .
> Si vous ne démentez pas immédiatement les affirmations de "incompétent"
ou ne les prouver pas je vais peut être suivre l'exemple de Brouard et
vous demander 20000 euro pour diffamation à l'encontre de ma personne et
ma société puisque cosignataires des messages alors fournissez vos
preuves ou excuser vous . Quand aux niveaux de compétence de Fred il
n'est plus à démontrer puisque il est de notoriété publique dans les
milieux compétents .
> Si vous ne démentez pas immédiatement les affirmations de "incompétent"
ou ne les prouver pas je vais peut être suivre l'exemple de Brouard et
vous demander 20000 euro pour diffamation à l'encontre de ma personne et
ma société puisque cosignataires des messages alors fournissez vos
preuves ou excuser vous . Quand aux niveaux de compétence de Fred il
n'est plus à démontrer puisque il est de notoriété publique dans les
milieux compétents .