Sample code for 30+ languages & platforms
Classic ASP

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 Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

'  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.

set email = Server.CreateObject("Chilkat.Email")
email.Subject = "Original"
email.From = "alice@example.com"
success = email.AddTo("Bob","bob@example.com")
email.Body = "Original body."

'  Copy the entire email into a new Email object.
set copy = Server.CreateObject("Chilkat.Email")

success = email.MakeCopy(copy)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( email.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "Copy subject: " & copy.Subject) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Copy NumTo: " & copy.NumTo) & "</pre>"

%>
</body>
</html>