Archived Forum Post

Index of archived forum posts


What exactly does Email.CreateReply and CreateForward do?

Feb 13 '13 at 22:09

What do the email object methods CreateForward and CreateReply exactly do?


The CreateReply and CreateForward methods return a new email object that is a pre-constructed reply or forward for the calling email object. For example:

CkEmail *reply = emailObject.CreateReply();
Chilkat.Email forward = emailObject.CreateForward();

Specifically, each method does the following:

CreateReply: The reply email is equal to the original email with the following changes:

1) The contents of the Subject header field is prepended with "RE: "
2) The plain-text body is prepended with:

-----Original Message-----
From: <from address>
Sent: <original email date header field contents>
To: <list of TO email addresses>
CC: <list of CC email addresses> (This line may not be present)
Subject: <original subject>

3) If an HTML body exists, the same information is prepended to the HTML body in a very simple way. The information is prepended before the opening "html" tag, if one exists, because email clients generally display it correctly.
4) The CC headers are cleared.
5) Various headers are removed: x-sender, x-rcpt-to, x-uidl, status, received, return-path, From, Reply-To
6) The Date header is initialized to the current date/time.
7) A new Message-ID header is generated.
8) The X-Priority header is replaced/added to be "3 (Normal)".
9) The TO header is initialized to the email address previously in the FROM header.

CreateForward: The forward email is equal to the original email with the following changes:

1) The Subject header is prepended with "FW: "
2) The plain-text and HTML bodies are modified in the same way as for CreateReply.
3) The TO and CC headers are cleared.
4) The various headers are removed just as in CreateReply.
5) The Date, Message-ID, and X-Priority are initialized just as in CreateReply.

Note: CreateReply and CreateForward are very simple methods to possibly make it quick and easy to create a reply or forward from an existing email. The behavior of these methods will not suit all possible needs, and there is nothing these methods do that cannot be duplicated via the email object (and MIME object) API's provided by Chilkat. If more sophisticated behavior is desired, then one should write application code that uses the functionality provided by the Chilkat email class, or potentially even the lower-level Chilkat MIME functionality, to generate the desired reply or forward.

Chilkat will not be changing the behavior of these methods to anything more sophisticated. In fact, it was probably a mistake to add these methods to the API in the first place, due to the simple fact that one set of behaviors will never satisfy the needs of all.