React Native Requires Chilkat v11.0.0+
React Native
Find the "Sent" IMAP Mailbox
See more IMAP Examples
Find the "Sent" IMAP mailbox. Also finds the Junk and Trash mailboxes..Chilkat React Native Downloads
import { Imap, Mailboxes } from '@chilkat/react-native'
async function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const imap = new Imap();
imap.ssl = true;
imap.port = 993;
try {
await imap.connectAsync('imap.yourmailserver.com');
} catch {
console.log(imap.lastErrorText);
return;
}
// Login or authenticate in some way..
try {
await imap.loginAsync('your_login', 'your_password');
} catch {
console.log(imap.lastErrorText);
return;
}
// Get the list of mailboxes.
const refName = '';
const wildcardedMailbox = '*';
const subscribed = false;
const mboxes = new Mailboxes();
try {
await imap.mbxListAsync(subscribed, refName, wildcardedMailbox, mboxes);
} catch {
console.log(imap.lastErrorText);
return;
}
// The mailbox with the "/Sent" flag is the "Sent" mailbox.
// Likewise for Junk and Trash..
let i = 0;
while (i < mboxes.count) {
if (mboxes.hasFlag(i, '\\Sent')) {
console.log(`Sent mailbox: ${mboxes.getName(i)}`);
}
if (mboxes.hasFlag(i, '\\Junk')) {
console.log(`Junk mailbox: ${mboxes.getName(i)}`);
}
if (mboxes.hasFlag(i, '\\Trash')) {
console.log(`Trash mailbox: ${mboxes.getName(i)}`);
}
i++;
}
// Disconnect from the IMAP server.
await imap.disconnectAsync();
}