React Native
React Native
Unsubscribe from an IMAP Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.Unsubscribe method, which removes the subscription to a mailbox. The mailbox itself and its messages are not deleted. This example unsubscribes from a mailbox.
Background: Unsubscribing simply drops a mailbox from the account's subscription list, so clients that show only subscribed folders will stop displaying it — the folder and everything in it remain on the server untouched. This is the counterpart to
Subscribe, and is how you declutter a mailbox listing without deleting anything (deleting a folder is DeleteMailbox).Chilkat React Native Downloads
import { Imap } from '@chilkat/react-native'
async function chilkatExample() {
// Demonstrates the Imap.Unsubscribe method, which removes the subscription to a mailbox.
// The mailbox itself and its messages are not deleted.
const imap = new Imap();
imap.ssl = true;
imap.port = 993;
try {
await imap.connectAsync('imap.example.com');
} catch {
console.log(imap.lastErrorText);
return;
}
try {
await imap.loginAsync('user@example.com', 'myPassword');
} catch {
console.log(imap.lastErrorText);
return;
}
// Remove the subscription to a mailbox (the mailbox is not deleted).
try {
await imap.unsubscribeAsync('Archive2026');
} catch {
console.log(imap.lastErrorText);
return;
}
console.log('Unsubscribed from the mailbox.');
try {
await imap.disconnectAsync();
} catch {
console.log(imap.lastErrorText);
return;
}
}