Sample code for 30+ languages & platforms
React Native

IMAP Session Logging

Demonstrates how to use session logging with IMAP.

Chilkat React Native Downloads

React Native
import { Imap } 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();

  // Set the KeepSessionLog property to enable IMAP session logging
  imap.keepSessionLog = true;

  // Connect to an IMAP server.
  // Use TLS
  imap.ssl = true;
  imap.port = 993;
  try {
    await imap.connectAsync('imap.example.com');
  } catch {
    console.log(imap.lastErrorText);
    return;
  }

  // Login
  try {
    await imap.loginAsync('mylogin', 'mypassword');
  } catch {
    console.log(imap.lastErrorText);
    return;
  }

  // Select an IMAP mailbox
  try {
    await imap.selectMailboxAsync('Inbox');
  } catch {
    console.log(imap.lastErrorText);
    return;
  }

  // We're not really doing anything in this example
  // other than to show how to examine the IMAP component's session log...

  // Disconnect from the IMAP server.
  await imap.disconnectAsync();

  // Display the session log...
  console.log(imap.sessionLog);
}