(SQL Server) Demonstrates how to call AddPfxSourceData for an Email Object
Demonstrates how to call AddPfxSourceData for an Email Object
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
DECLARE @fac int
-- Use "Chilkat_9_5_0.FileAccess" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.FileAccess', @fac OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
EXEC sp_OAMethod @fac, 'ReadEntireFile', @pfxBytes OUT, 'qa_data/pfx/some.pfx'
DECLARE @email int
-- Use "Chilkat_9_5_0.Email" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Email', @email OUT
DECLARE @success int
EXEC sp_OAMethod @email, 'AddPfxSourceData', @success OUT, @pfxBytes, 'PFX_PASSWORD'
IF @success <> 1
BEGIN
EXEC sp_OAGetProperty @email, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @fac
EXEC @hr = sp_OADestroy @email
RETURN
END
PRINT 'Success.'
EXEC @hr = sp_OADestroy @fac
EXEC @hr = sp_OADestroy @email
END
GO
|