SQL Server
SQL Server
Create a Message Disposition Notification (MDN)
See more Email Object Examples
Demonstrates the Chilkat Email.ToMdn method, which creates a new MDN (Message Disposition Notification) email in the format specified by RFC 3798, based on this email. The generated MDN is returned in the last argument, and the source email is not modified. The first argument is the human-readable message, the second is the disposition fields, and the third indicates whether to include headers only. This example builds an MDN for a received message.
Background: An MDN is the formal "read receipt" — the response returned (with the user's consent) when a message requesting a receipt is opened. Like a DSN it is a
multipart/report, but it carries a message/disposition-notification part describing what happened to the message (for example, displayed). ToMdn generates that report, which pairs with the ReturnReceipt property that requests one.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
-- Demonstrates the ToMdn method, which creates a new MDN (Message Disposition Notification)
-- email (RFC 3798) based on this email. The generated MDN is returned in the last argument.
-- The source email is not modified.
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_OAMethod @email, 'LoadEml', @success OUT, 'qa_data/eml/received.eml'
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @email, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @email
RETURN
END
-- Create an MDN (read receipt) for the received message. The 1st argument is the
-- human-readable message, the 2nd is the disposition fields, and the 3rd (headerOnly) is false.
DECLARE @mdn int
EXEC @hr = sp_OACreate 'Chilkat.Email', @mdn OUT
EXEC sp_OAMethod @email, 'ToMdn', @success OUT, 'Your message has been displayed.', 'Disposition: manual-action/MDN-sent-manually; displayed', 0, @mdn
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @email, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @email
EXEC @hr = sp_OADestroy @mdn
RETURN
END
-- Populate additional sender/recipient fields on the MDN before sending, then send it.
EXEC sp_OAMethod @mdn, 'GetMime', @sTmp0 OUT
PRINT @sTmp0
-- Note: The path "qa_data/..." is a relative local filesystem path,
-- relative to the current working directory of the running application.
EXEC @hr = sp_OADestroy @email
EXEC @hr = sp_OADestroy @mdn
END
GO