question

smuchakurti avatar image
smuchakurti asked

Getting '-2147221005': 'Invalid class string' error while trying to create objects using 'sp_OACreate' on SQL Server 2012.

I am trying to run the below script that creates 'EASendMailObj.Mail' object using 'sp_OACreate' but getting '-2147221005': 'Invalid class string' error. What could be the issue?

DECLARE @hr int 
DECLARE @oSmtp int
DECLARE @result int
DECLARE @description nvarchar(255)
EXEC @hr = sp_OACreate 'EASendMailObj.Mail',@oSmtp OUT
print @hr
If @hr <> 0
BEGIN
EXEC @hr = sp_OAGetErrorInfo @oSmtp, NULL, @description OUT
IF @hr = 0
BEGIN
PRINT @description
END
RETURN End
sql server 2012
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

WRBI avatar image WRBI commented ·

I don't have any experience with doing this. However, investigation on the code showed the below. The documentation for sp_OAGetErrorInfo (MSDN Link). The MSDN Article indicates:

Invalid class string - Specified ProgID or CLSID is not registered as an OLE object on an instance of SQL Server. Custom OLE automation servers must be registered before they can be instantiated using sp_OACreate. This can be done by using the Regsvr32.exe utility for in-process (.dll) servers, or the /REGSERVER command-line switch for local (.exe) servers.

Could this be the issue?

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.