Sample code for 30+ languages & platforms
Classic ASP Requires Chilkat v11.0.0+

Forward an email as an attachment

See more Email Object Examples

Attach the original Email to a new message as a message/rfc822 part. The recipient can open the attached email and read its original headers and body.

Chilkat Classic ASP Downloads

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

'  Assumes Chilkat is unlocked. See Global Unlock Sample.

set original = Server.CreateObject("Chilkat.Email")
success = original.LoadEml("message.eml")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( original.LastErrorText) & "</pre>"
    Response.End
End If

set email = Server.CreateObject("Chilkat.Email")
email.From = "Sam Lee <sam@example.com>"
success = email.AddTo("Alex Rivera","alex@example.net")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( email.LastErrorText) & "</pre>"
    Response.End
End If

email.Subject = "Forwarded message"
email.Body = "The original email is attached."
success = email.AttachEmail(original)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( email.LastErrorText) & "</pre>"
    Response.End
End If

success = email.SaveEml("forward-as-attachment.eml")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( email.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "Saved forward-as-attachment.eml.") & "</pre>"

%>
</body>
</html>