Dart
Dart
Attach Email as message/rfc822 sub-part to an Email
See more Email Object Examples
Demonstrates how to add attach a message/rfc822 email to another email.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// In this example, we'll attach an email loaded from a .eml file to a new email.
final fac = CkFileAccess();
final emlBytes = fac.readEntireFile('qa_data/eml/simple.eml');
final email = CkEmail();
email.subject = 'This is a test email with an attached email.';
email.body = 'Test with attached email.';
email.addTo('Joe', 'joe@example.com');
email.from = 'mary@example.com';
email.attachMessage(emlBytes);
print(email.getMime());
// ----------------------------------------------------------------------
// Alternatively, we could do this:
final emailToBeAttached = CkEmail();
emailToBeAttached.loadEml('qa_data/eml/simple.eml');
final email2 = CkEmail();
email2.subject = 'This is a test email with an attached email.';
email2.body = 'Test with attached email.';
email2.addTo('Joe', 'joe@example.com');
email2.from = 'mary@example.com';
final emlBytes2 = emailToBeAttached.getMimeBinary();
email2.attachMessage(emlBytes2);
print('----');
print(email2.getMime());
}