Unicode C
Unicode C
Make a Copy of an Email
See more Email Object Examples
Demonstrates the Chilkat Email.MakeCopy method, which copies the entire state of this email into another Email object — message content, recipients, headers, body representations, attachments, and related items. This example copies an email and reads a couple of fields from the copy.
Background: A deep copy gives you an independent duplicate: changes to one object do not affect the other. This is handy for template-and-tweak workflows — build a base message once, copy it per recipient, then vary only the recipient or a few fields — without risk of one send's edits bleeding into the next.
Chilkat Unicode C Downloads
#include <C_CkEmailW.h>
void ChilkatSample(void)
{
BOOL success;
HCkEmailW email;
HCkEmailW copy;
success = FALSE;
// Demonstrates the MakeCopy method, which copies the entire state of this email into
// another Email object -- message content, recipients, headers, bodies, attachments, and
// related items.
email = CkEmailW_Create();
CkEmailW_putSubject(email,L"Original");
CkEmailW_putFrom(email,L"alice@example.com");
CkEmailW_AddTo(email,L"Bob",L"bob@example.com");
CkEmailW_putBody(email,L"Original body.");
// Copy the entire email into a new Email object.
copy = CkEmailW_Create();
success = CkEmailW_MakeCopy(email,copy);
if (success == FALSE) {
wprintf(L"%s\n",CkEmailW_lastErrorText(email));
CkEmailW_Dispose(email);
CkEmailW_Dispose(copy);
return true;
}
wprintf(L"Copy subject: %s\n",CkEmailW_subject(copy));
wprintf(L"Copy NumTo: %d\n",CkEmailW_getNumTo(copy));
CkEmailW_Dispose(email);
CkEmailW_Dispose(copy);
}