mostafa saeed

mostafa saeed

  • NA
  • 19
  • 4.1k

I am using below given procedure to send SMS from SQL Server

May 19 2019 2:24 PM
I am using below given procedure to send SMS from SQL Server. It's working fine till yesterday night.
 
But, today I am getting following error:
 
-2146697212 Msg 50000, Level 16, State 1, Procedure pr_SendSmsSQL, Line 61
sp_OAMethod Send FAILED!
 
Error Source Description
 
msxml3.dll Unable to connect to the target server.
 
ALTER Procedure [dbo].[pr_SendSmsSQL] @MobileNo varchar(12), @smstext as varchar(300), @sResponse varchar(1000) OUT as BEGIN Declare @iReq int,@hr int Declare @sUrl as varchar(500) DECLARE @errorSource VARCHAR(8000) DECLARE @errorDescription VARCHAR(8000) -- Create Object for XMLHTTP EXEC @hr = sp_OACreate 'Microsoft.XMLHTTP', @iReq OUT print @hr if @hr <> 0 Raiserror('sp_OACreate Microsoft.XMLHTTP FAILED!', 16, 1) set @sUrl='http://122.22.12.12/smsportal/sendsms.aspx?usr=test&pass=test&senderid=BSethi24&mobileno=#MobNo#&messagetext=#Msg#' set @sUrl=REPLACE(@sUrl,'#MobNo#',@MobileNo) set @sUrl=REPLACE(@sUrl,'#Msg#',@smstext) print @sUrl -- sms code start EXEC @hr = sp_OAMethod @iReq, 'Open', NULL, 'GET', @sUrl, true print @hr if @hr <> 0 Raiserror('sp_OAMethod Open FAILED!', 16, 1) EXEC @hr = sp_OAMethod @iReq, 'send' select @iReq print @hr if @hr <> 0 Begin EXEC sp_OAGetErrorInfo @iReq, @errorSource OUTPUT, @errorDescription OUTPUT SELECT [Error Source] = @errorSource, [Description] = @errorDescription Raiserror('sp_OAMethod Send FAILED!', 16, 1) end else Begin EXEC @hr = sp_OAGetProperty @iReq,'responseText', @sResponse OUT print @hr insert into s_SmsLog (Id,Mobile_No,SMSText,SMSResponse,Created_By,Created_Date,Modified_By,Modified_Date) values(0,@MobileNo,@smstext,@sResponse,'System',GETDATE(),null,null) End

Answers (2)