Dart Requires Chilkat v11.0.0+
Dart
Find the "Sent" IMAP Mailbox
See more IMAP Examples
Find the "Sent" IMAP mailbox. Also finds the Junk and Trash mailboxes..Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final imap = CkImap();
imap.ssl = true;
imap.port = 993;
try {
imap.connect('imap.yourmailserver.com');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// Login or authenticate in some way..
try {
imap.login('your_login', 'your_password');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// Get the list of mailboxes.
final refName = '';
final wildcardedMailbox = '*';
final subscribed = false;
final mboxes = CkMailboxes();
try {
imap.mbxList(subscribed, refName, wildcardedMailbox, mboxes);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// The mailbox with the "/Sent" flag is the "Sent" mailbox.
// Likewise for Junk and Trash..
var i = 0;
while (i < mboxes.count) {
if (mboxes.hasFlag(i, '\\Sent')) {
print('Sent mailbox: ${mboxes.getName(i)}');
}
if (mboxes.hasFlag(i, '\\Junk')) {
print('Junk mailbox: ${mboxes.getName(i)}');
}
if (mboxes.hasFlag(i, '\\Trash')) {
print('Trash mailbox: ${mboxes.getName(i)}');
}
i++;
}
// Disconnect from the IMAP server.
imap.disconnect();
}