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

POP3 Fetch Mime Source of Email by UIDL

Demonstrates how to fetch the MIME source of a single email by UIDL.

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.

  final mailman = CkMailMan();

  mailman.mailHost = 'pop.example.com';

  mailman.popUsername = 'myLogin';
  mailman.popPassword = 'myPassword';

  mailman.mailPort = 995;
  mailman.popSsl = true;

  final stUidls = CkStringTable();
  try {
    mailman.fetchUidls(stUidls);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  // Download each email as MIME.
  final bdMime = CkBinData();

  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;
    }

    // Do whatever is needed with the MIME contained in bdMime.

    i++;
  }
}