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

Download POP3 Email to MIME

Download the email from a POP3 mailbox directly into MIME, without parsing into email objects.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  // This example requires the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  // The mailman object is used for receiving (POP3) 
  // and sending (SMTP) email.
  final mailman = CkMailMan();

  // Set the POP3 server's hostname
  mailman.mailHost = 'pop.example.com';

  // Set the POP3 login/password.
  mailman.popUsername = 'myLogin';
  mailman.popPassword = 'myPassword';

  // First, get the complete set of UIDLs for the email in the POP3 mailbox:
  final stUidls = CkStringTable();
  try {
    mailman.fetchUidls(stUidls);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  // Download each email as MIME.
  // If desired, the MIME can be loaded into an email object.
  final bdMime = CkBinData();
  final email = CkEmail();

  final count = stUidls.count;
  var i = 0;
  while (i < count) {
    try {
      mailman.fetchMimeBd(stUidls.stringAt(i), bdMime);
    } on ChilkatException catch (e) {
      print(e.lastErrorText);
      return;
    }

    email.setFromMimeBd(bdMime);
    print('From: ${email.from}');
    print('Subject: ${email.subject}');

    i++;
  }
}