Dart Requires Chilkat v11.0.0+
Dart
Download POP3 Email using UIDLs
Demonstrates how to download POP3 email by first getting the complete set of UIDLs and then downloading email by calling FetchByUIDL for each UIDL.Chilkat Dart Downloads
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';
final stUidls = CkStringTable();
try {
mailman.fetchUidls(stUidls);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final email = CkEmail();
final count = stUidls.count;
var i = 0;
while (i < count) {
// Download the full email.
try {
mailman.fetchByUidl(stUidls.stringAt(i), false, 0, email);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print(i);
print('From: ${email.from}');
print('Subject: ${email.subject}');
i++;
}
mailman.pop3EndSession();
}