Sample code for 30+ languages & platforms
React Native Requires Chilkat v11.0.0+

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 React Native Downloads

React Native
import { Email, MailMan, StringTable } from '@chilkat/react-native'

async function chilkatExample() {
  // 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.
  const mailman = new MailMan();

  // Set the POP3 server's hostname
  mailman.mailHost = 'pop.example.com';

  // Set the POP3 login/password.
  mailman.popUsername = 'myLogin';
  mailman.popPassword = 'myPassword';

  const stUidls = new StringTable();
  try {
    await mailman.fetchUidlsAsync(stUidls);
  } catch {
    console.log(mailman.lastErrorText);
    return;
  }

  const email = new Email();

  const count = stUidls.count;
  let i = 0;
  while (i < count) {
    // Download the full email.
    try {
      await mailman.fetchByUidlAsync(stUidls.stringAt(i), false, 0, email);
    } catch {
      console.log(mailman.lastErrorText);
      return;
    }

    console.log(i);
    console.log(`From: ${email.from}`);
    console.log(`Subject: ${email.subject}`);

    i++;
  }

  await mailman.pop3EndSessionAsync();
}