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

Retrieve UIDL's from POP3 Server

Retrieve a list of UIDLs from a POP3 server. UIDLs are unique identifiers, 1 to 70 characters long, composed of characters ranging from 0x21 to 0x7E. These identifiers uniquely distinguish messages within a mailbox and remain consistent across sessions.

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 by UIDL.
  final email = CkEmail();

  final count = stUidls.count;
  var i = 0;
  while (i < count) {
    // Download the full email.
    final uidl = stUidls.stringAt(i);
    try {
      mailman.fetchByUidl(uidl, false, 0, email);
    } on ChilkatException catch (e) {
      print(e.lastErrorText);
      return;
    }

    print(i);
    print('UIDL: $uidl');
    print('From: ${email.from}');
    print('Subject: ${email.subject}');

    i++;
  }

  mailman.pop3EndSession();
}