Hi all,We use a stored procedure to send mail using CDO.Message. We have a requirement to send certain mails marked as private. I've searched the Microsoft knowledge bases and I'm sure I'm 90% there but no matter what I do it doesn't send mails marked as private.Here the bare bones of the sp before any changes. (without the error checking etc)/****** Object: StoredProcedure [dbo].[sp_CS_send_private_cdosysmail] Script Date: 05/23/2008 09:56:57 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE sp_CS_send_private_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 BEGIN Declare @iMsg int Declare @hr int Declare @source varchar(255) Declare @description varchar(500) Declare @output varchar(1000) -- set the SMTPServer by name or IP Declare @SMTPServer varchar(255) set @SMTPServer = 'electra' -- --************* 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/sendusing").Value','2' -- This is to configure the Server Name or IP address. EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value', @SMTPServer -- 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, 'HTMLBody', @Body -- Send the email allready... EXEC @hr = sp_OAMethod @iMsg, 'Send', NULLEND
I've tried adding the following line before calling "EXEC @hr = sp_OAMethod @iMsg, 'Configuration.Fields.Update', null" to save the headers...EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.microsoft.com/exchange/sensitivity").Value', '2'
to set the message to private (taken from http://msdn.microsoft.com/en-us/library/ms527271(EXCHG.10).aspx) which details the asp called to the message object.sp_OASetProperty accepts this fine, returns no error and the mail does go out. however it isn't marked Private. I've tried lots of different variations but nothing seems to work.Any help? I'm out of ideas.-------------Charlie