Object reference not set to an instance of an object.

Any Chilkat method that returns an object will return a NULL reference if the method failed. You should check for NULL and then examine the contents of the LastErrorText property. Here are examples in various programming languages:
C#

//  Fetch the emails into a bundle object:
Chilkat.EmailBundle bundle = null;
bundle = imap.FetchBundle(messageSet);
if (bundle == null ) {
    MessageBox.Show(imap.LastErrorText);
    return;
}

VB.NET

'  Fetch the emails into a bundle object:
Dim bundle As Chilkat.EmailBundle
bundle = imap.FetchBundle(messageSet)
If (bundle Is Nothing ) Then
    MsgBox(imap.LastErrorText)
    Exit Sub
End If

Visual Basic 6.0

'  Fetch the emails into a bundle object:
Dim bundle As ChilkatEmailBundle2
Set bundle = imap.FetchBundle(messageSet)
If (bundle Is Nothing ) Then
    MsgBox imap.LastErrorText
    Exit Sub
End If

Delphi

//  Fetch the emails into a bundle object:
bundle := imap.FetchBundle(messageSet);
if (bundle = nil ) then
  begin
    ShowMessage(imap.LastErrorText);
    Exit;
  end;

Visual FoxPro

*  Fetch the emails into a bundle object:
loBundle = loImap.FetchBundle(loMessageSet)
IF (loBundle = NULL ) THEN
    =MESSAGEBOX(loImap.LastErrorText)
    QUIT
ENDIF

C++

    //  Fetch the emails into a bundle object:
    CkEmailBundle *bundle = 0;
    bundle = imap.FetchBundle(*messageSet);
    if (bundle == 0 ) {
        printf("%s\n",imap.lastErrorText());
        return;
    }

Java

    //  Fetch the emails into a bundle object:
    CkEmailBundle bundle;
    bundle = imap.FetchBundle(messageSet);
    if (bundle == null ) {
        System.out.println(imap.lastErrorText());
        return;
    }

Perl

#  Fetch the emails into a bundle object:
# bundle is a CkEmailBundle
$bundle = $imap->FetchBundle($messageSet);
if ($bundle eq null ) {
    print $imap->lastErrorText() . "\n";
    exit;
}

Python

# bundle is a CkEmailBundle
bundle = imap.FetchBundle(messageSet)
if (bundle == None ):
    print imap.lastErrorText()
    sys.exit()

Ruby

# bundle is a CkEmailBundle
bundle = imap.FetchBundle(messageSet)
if (bundle == nil )
    print imap.lastErrorText() + "\n"
    exit
end

SQL Server

    --  Fetch the emails into a bundle object:
    DECLARE @bundle int
    EXEC sp_OAMethod @imap, 'FetchBundle', @bundle OUT, @messageSet
    IF @bundle Is NULL 
      BEGIN
        EXEC sp_OAGetProperty @imap, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        RETURN
      END