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,
-- =========================================
-- 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,