hi everyone,
i am using sql server 2008 r2 express edition for sending email using CDO i have configured everthing such as
"
exec sp_configure 'show advanced options', 1
exec sp_configure 'Database Mail XPs', 1
exec sp_configure 'Agent XPs',1
"
and after that create a procedure
alter PROCEDURE sp_send_mail_HRrept
@from varchar(500) ,
@to varchar(500) ,
@subject varchar(max),
@body varchar(max) ,
@bodytype varchar(10),
@output_mesg varchar(10) output,
@output_desc varchar(1000) output
AS
DECLARE @imsg int
DECLARE @hr int
DECLARE @source varchar(255)
DECLARE @description varchar(500)
--Create an OLE Instance of CDO
EXEC @hr = sp_oacreate 'cdo.message', @imsg out
--SendUsing
EXEC @hr = sp_oasetproperty @imsg,'configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendusing").value','2'
--smtpserver
EXEC @hr = sp_oasetproperty @imsg,'configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpserver").value', 'mail.abc.com'
--sendusername
EXEC @hr = sp_oasetproperty @imsg,'configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendusername").value', 'sender@abc.com'
--sendpassword
EXEC @hr = sp_oasetproperty @imsg,'configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendpassword").value', 'XXXXXXX'
--smtpusessl
EXEC @hr = sp_oasetproperty @imsg,'configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl").value', 'False'
--smtpserverport
EXEC @hr = sp_oasetproperty @imsg,'configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport").value', '25'
--smtpauthenticate
EXEC @hr = sp_oasetproperty @imsg,'configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").value', '1'
--Send Email
--Execute the OLE object to send email
EXEC @hr = sp_oamethod @imsg, 'configuration.fields.update', null
EXEC @hr = sp_oasetproperty @imsg, 'to', @to
EXEC @hr = sp_oasetproperty @imsg, 'from', @from
EXEC @hr = sp_oasetproperty @imsg, 'subject', @subject
EXEC @hr = sp_oasetproperty @imsg, @bodytype, @body
--EXEC @hr = sp_OAMethod @iMsg,'AddAttachment', NULL, 'F:\Mindz Hire.ppsx'
--EXEC @hr = sp_OAMethod @iMsg,'AddAttachment', NULL, 'F:\ppt\corporate_giftts_2.pdf'
--EXEC @hr = sp_OAMethod @iMsg,'AddAttachment', NULL, 'F:\ppt\Mindztechnology.ppt'
--EXEC @hr = sp_OAMethod @iMsg,'AddAttachment', NULL, 'C:\ppt\corporate_giftts_2.pdf'
--EXEC @hr = sp_OAMethod @iMsg,'AddAttachment', NULL, 'F:\mindz\MindZ-Technology.pptx'
--EXEC @hr = sp_OAMethod @iMsg,'AddAttachment', NULL, 'F:\mindz\MProFinders.pptx'
EXEC @hr = sp_oamethod @imsg, 'send', null
--Error Handling `
--Below snippet is checking if the mail is send successfully. If not it captures the Error message and the
--Error Description in the output variables
SET @output_mesg = 'Success'
IF @hr <>0
SELECT @hr
declare @email_id uniqueidentifier
BEGIN
EXEC @hr = sp_oageterrorinfo null, @source out, @description out
IF @hr = 0
BEGIN
set @output_desc = @description
END
ELSE
BEGIN
SET @output_desc = ' sp_oageterrorinfo failed'
select @output_desc as output_desc
END
IF not @output_desc is NULL
SET @output_mesg = 'Error'
select @output_mesg as output_mesg
END
-----------------------------------------------------------------------------------------
but when i run this proc always getting error "-2147220975"
i have done too much googling but do not found any information about this error code
i hope someone help me as soon as possible .
Thanks