Sample code for 30+ languages & platforms
React Native Requires Chilkat v11.0.0+

Access Attached Message (Embedded Email)

How to access an email embedded within another email (i.e. an attached message).

Chilkat React Native Downloads

React Native
import { Email } from '@chilkat/react-native'

function chilkatExample() {
  const email = new Email();

  // Load an email from a .eml
  try {
    email.loadEml('embeddedEmail.eml');
  } catch {
    console.log(email.lastErrorText);
    return;
  }

  // Display how many attached emails are embedded within
  // this one:
  const numAttached = email.numAttachedMessages;
  console.log(`numAttached = ${numAttached}`);

  // Get the 1st attached message.
  const email2 = new Email();
  try {
    email.getAttachedEmail(0, email2);

    // Display the subject, From, and a header field...
    console.log(email2.subject);
    console.log(email2.from);
    console.log(email2.getHeaderField('X-SOMETHING'));
  } catch {
    // email.getAttachedEmail() failed; continue anyway.
  }
}