Get Return Queue ID From SP_Send_DBMail in SQL Server

Pada posting "Get Return Queue ID From SP_Send_DBMail in SQL Server" akan diberikan sample cara mendapatkan Queue ID dari SP_SendDBMail.


-- =========================================
-- Author           : MAS
-- Create date    : 10 Juli 2018
-- Description    : Send Mail : text or html
-- ==========================================

CREATE PROCEDURE [dbo].[sp_sendmail]
@Destination varchar(256), @Subject varchar(256), @MailBody varchar(5000), @Format varchar(10)
AS
BEGIN
    SET NOCOUNT ON;
       
    DECLARE @mailitem_id Int;
    DECLARE @message Varchar(50);

    BEGIN TRY

        EXEC msdb.dbo.sp_send_dbmail
                @profile_name ='ProfileMailHO',
                @recipients = @Destination,
                @subject = @Subject,
                @body = @MailBody,
                @body_format = @Format,
                @mailitem_id = @mailitem_id OUTPUT
       
        IF ISNULL(@mailitem_id, 0) = 0
        BEGIN
            SELECT 0, 'Fail' As Result
        END
        ELSE
        BEGIN
            SELECT @mailitem_id, 'Success' As Result
        END
       
    END TRY
    BEGIN CATCH
        SELECT @mailitem_id, ERROR_MESSAGE() As Result
    END CATCH
       
END


Semoga posting tentang "Get Return Queue ID From SP_Send_DBMail in SQL Server" ini dapat bermanfaat.


Salam,

Popular posts from this blog

K2 Error Value Cannot Be Null. Parameter Name: s In SmartView and SmartObject

Cara inject USB 3.0 Driver pada instalasi Windows - How to Inject USB 3.0 Driver in Windows 7

Pentaho Spoon Error : "Could Not Create The Java Virtual Machine"