Sample code for 30+ languages & platforms
Classic ASP

Load an Email from a .eml File

See more Email Object Examples

Demonstrates the Chilkat Email.LoadEml method, which loads a complete email from an .eml file. An EML file contains RFC822/MIME message text. On success, the loaded message replaces the entire current email — recipients, headers, bodies, related items, and attachments. This example loads an EML and reads its subject and from.

Background: .eml is the standard on-disk format for a single email — it is simply the raw MIME saved to a file, which most mail clients can export and open. LoadEml parses that MIME into a fully populated Email object, giving you programmatic access to every part. It is the natural counterpart to SaveEml.

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 LoadEml method, which loads a complete email from an .eml file (an EML
'  file contains RFC822/MIME message text).  On success, the loaded message replaces the
'  entire current email.

set email = Server.CreateObject("Chilkat.Email")

success = email.LoadEml("qa_data/eml/message.eml")
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( email.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "Subject: " & email.Subject) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "From: " & email.From) & "</pre>"

'  Note: The path "qa_data/..." is a relative local filesystem path,
'  relative to the current working directory of the running application.

%>
</body>
</html>