SQL Server
SQL Server
Create a Reply Email
See more Email Object Examples
Demonstrates the Chilkat Email.ToReply method, which generates a reply email with updated header and body fields so it can be sent as a reply. Attachments are excluded from the reply, but attached messages are included. The source email is not modified. This example creates a reply and prints its MIME.
Background: Replying is more than swapping sender and recipient: the
To is set from the original's reply address, the subject gets an Re: prefix, the original text is quoted, and threading headers (In-Reply-To, References) are added so mail clients group the conversation. ToReply assembles all of that, leaving a message you can edit and send. Dropping attachments is the usual reply convention — you rarely echo the sender's files back to them.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
-- Demonstrates the ToReply method, which generates a reply email with updated header and
-- body fields ready to send as a reply. Attachments are excluded from the reply, but
-- attached messages are included. 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_OASetProperty @email, 'Subject', 'Project update'
EXEC sp_OASetProperty @email, 'From', 'alice@example.com'
EXEC sp_OAMethod @email, 'AddTo', @success OUT, 'Bob', 'bob@example.com'
EXEC sp_OASetProperty @email, 'Body', 'Here is the project update.'
-- Create a reply email based on this message.
DECLARE @reply int
EXEC @hr = sp_OACreate 'Chilkat.Email', @reply OUT
EXEC sp_OAMethod @email, 'ToReply', @success OUT, @reply
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @email, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @email
EXEC @hr = sp_OADestroy @reply
RETURN
END
-- The reply is addressed and quoted, ready to edit and send.
EXEC sp_OAMethod @reply, 'GetMime', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @email
EXEC @hr = sp_OADestroy @reply
END
GO