Sample code for 30+ languages & platforms
SQL Server Requires Chilkat v11.0.0+

Set the display priority of a message

See more Email Object Examples

Set X-Priority to 1 (high), 3 (normal), or 5 (low). A mail reader can use it as a display hint. SMTP delivery order is controlled by the mail system.

Chilkat SQL Server Downloads

SQL Server
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @success int
    SELECT @success = 0

    --  Assumes Chilkat is unlocked. See Global Unlock Sample.

    DECLARE @email int
    EXEC @hr = sp_OACreate 'Chilkat.Email', @email OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OASetProperty @email, 'From', 'Workshop team <events@example.com>'
    EXEC sp_OAMethod @email, 'AddTo', @success OUT, 'Alex Rivera', 'alex@example.net'
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @email, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @email
        RETURN
      END
    EXEC sp_OASetProperty @email, 'Subject', 'Workshop venue change'
    EXEC sp_OASetProperty @email, 'Body', 'Please use the north entrance.'
    EXEC sp_OAMethod @email, 'AddHeaderField', NULL, 'X-Priority', '1 (High)'

    EXEC sp_OAMethod @email, 'GetHeaderField', @sTmp0 OUT, 'X-Priority'
    PRINT 'Priority: ' + @sTmp0

    EXEC sp_OAMethod @email, 'SaveEml', @success OUT, 'venue-change.eml'
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @email, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @email
        RETURN
      END

    PRINT 'Saved venue-change.eml.'

    EXEC @hr = sp_OADestroy @email


END
GO